Skip to content

Commit

Permalink
Update dawn + reuse format + print message
Browse files Browse the repository at this point in the history
  • Loading branch information
beaufortfrancois committed May 21, 2024
1 parent 1a5995e commit 9370eb7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[submodule "dawn"]
path = dawn
url = https://dawn.googlesource.com/dawn
branch = chromium/6167 # Chrome 121
branch = chromium/6478 # Chrome 126
shallow = true
2 changes: 1 addition & 1 deletion dawn
Submodule dawn updated from 12b225 to fda42b
15 changes: 11 additions & 4 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ wgpu::Device device;
wgpu::RenderPipeline pipeline;

wgpu::Surface surface;
wgpu::TextureFormat format;
const uint32_t kWidth = 512;
const uint32_t kHeight = 512;

void ConfigureSurface() {
wgpu::SurfaceCapabilities capabilities;
surface.GetCapabilities(adapter, &capabilities);
format = capabilities.formats[0];

wgpu::SurfaceConfiguration config{
.device = device,
.format = format,
.alphaMode = capabilities.alphaModes[0],
.width = kWidth,
.height = kHeight,
.format = capabilities.formats[0],
.alphaMode = capabilities.alphaModes[0],
.presentMode = capabilities.presentModes[0]};
surface.Configure(&config);
}
Expand All @@ -37,6 +39,9 @@ void GetAdapter(void (*callback)(wgpu::Adapter)) {
// wgpu::RequestAdapterStatus and wgpu::Adapter.
[](WGPURequestAdapterStatus status, WGPUAdapter cAdapter,
const char* message, void* userdata) {
if (message) {
printf("RequestAdapter: %s\n", message);
}
if (status != WGPURequestAdapterStatus_Success) {
exit(0);
}
Expand All @@ -52,6 +57,9 @@ void GetDevice(void (*callback)(wgpu::Device)) {
// wgpu::RequestDeviceStatus and wgpu::Device.
[](WGPURequestDeviceStatus status, WGPUDevice cDevice,
const char* message, void* userdata) {
if (message) {
printf("RequestDevice: %s\n", message);
}
wgpu::Device device = wgpu::Device::Acquire(cDevice);
device.SetUncapturedErrorCallback(
[](WGPUErrorType type, const char* message, void* userdata) {
Expand Down Expand Up @@ -82,8 +90,7 @@ void CreateRenderPipeline() {
wgpu::ShaderModule shaderModule =
device.CreateShaderModule(&shaderModuleDescriptor);

wgpu::ColorTargetState colorTargetState{
.format = wgpu::TextureFormat::BGRA8Unorm};
wgpu::ColorTargetState colorTargetState{.format = format};

wgpu::FragmentState fragmentState{.module = shaderModule,
.targetCount = 1,
Expand Down

0 comments on commit 9370eb7

Please sign in to comment.