Skip to content

Commit b9c96db

Browse files
replace WGPUSwapChain with methods for WGPUSurface
1 parent 64db862 commit b9c96db

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

webgpu.h

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ typedef struct WGPURenderPipelineImpl* WGPURenderPipeline;
8282
typedef struct WGPUSamplerImpl* WGPUSampler;
8383
typedef struct WGPUShaderModuleImpl* WGPUShaderModule;
8484
typedef struct WGPUSurfaceImpl* WGPUSurface;
85-
typedef struct WGPUSwapChainImpl* WGPUSwapChain;
8685
typedef struct WGPUTextureImpl* WGPUTexture;
8786
typedef struct WGPUTextureViewImpl* WGPUTextureView;
8887

@@ -575,6 +574,15 @@ typedef enum WGPUVertexStepMode {
575574
WGPUVertexStepMode_Force32 = 0x7FFFFFFF
576575
} WGPUVertexStepMode;
577576

577+
typedef enum WGPUSurfaceStatus {
578+
WGPUSurfaceStatus_Good = 0x00000000,
579+
WGPUSurfaceStatus_Suboptimal = 0x00000001,
580+
WGPUSurfaceStatus_Timeout = 0x00000002,
581+
WGPUSurfaceStatus_Outdated = 0x00000003,
582+
WGPUSurfaceStatus_Lost = 0x00000004,
583+
WGPUSurfaceStatus_Force32 = 0x7FFFFFFF
584+
} WGPUSurfaceStatus;
585+
578586
typedef enum WGPUBufferUsage {
579587
WGPUBufferUsage_None = 0x00000000,
580588
WGPUBufferUsage_MapRead = 0x00000001,
@@ -944,15 +952,17 @@ typedef struct WGPUSurfaceDescriptorFromXlibWindow {
944952
uint32_t window;
945953
} WGPUSurfaceDescriptorFromXlibWindow;
946954

947-
typedef struct WGPUSwapChainDescriptor {
955+
typedef struct WGPUSurfaceConfiguration {
948956
WGPUChainedStruct const * nextInChain;
949-
char const * label; // nullable
950-
WGPUTextureUsageFlags usage;
957+
WGPUDevice device;
951958
WGPUTextureFormat format;
959+
WGPUTextureUsageFlags usage;
960+
uint32_t viewFormatsCount;
961+
WGPUTextureFormat const * viewFormats;
952962
uint32_t width;
953963
uint32_t height;
954964
WGPUPresentMode presentMode;
955-
} WGPUSwapChainDescriptor;
965+
} WGPUSurfaceConfiguration;
956966

957967
typedef struct WGPUTextureBindingLayout {
958968
WGPUChainedStruct const * nextInChain;
@@ -1268,7 +1278,6 @@ typedef WGPURenderPipeline (*WGPUProcDeviceCreateRenderPipeline)(WGPUDevice devi
12681278
typedef void (*WGPUProcDeviceCreateRenderPipelineAsync)(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallback callback, void * userdata);
12691279
typedef WGPUSampler (*WGPUProcDeviceCreateSampler)(WGPUDevice device, WGPUSamplerDescriptor const * descriptor /* nullable */);
12701280
typedef WGPUShaderModule (*WGPUProcDeviceCreateShaderModule)(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor);
1271-
typedef WGPUSwapChain (*WGPUProcDeviceCreateSwapChain)(WGPUDevice device, WGPUSurface surface, WGPUSwapChainDescriptor const * descriptor);
12721281
typedef WGPUTexture (*WGPUProcDeviceCreateTexture)(WGPUDevice device, WGPUTextureDescriptor const * descriptor);
12731282
typedef void (*WGPUProcDeviceDestroy)(WGPUDevice device);
12741283
typedef size_t (*WGPUProcDeviceEnumerateFeatures)(WGPUDevice device, WGPUFeatureName * features);
@@ -1354,10 +1363,10 @@ typedef void (*WGPUProcShaderModuleSetLabel)(WGPUShaderModule shaderModule, char
13541363

13551364
// Procs of Surface
13561365
typedef WGPUTextureFormat (*WGPUProcSurfaceGetPreferredFormat)(WGPUSurface surface, WGPUAdapter adapter);
1357-
1358-
// Procs of SwapChain
1359-
typedef WGPUTextureView (*WGPUProcSwapChainGetCurrentTextureView)(WGPUSwapChain swapChain);
1360-
typedef void (*WGPUProcSwapChainPresent)(WGPUSwapChain swapChain);
1366+
typedef void (*WGPUProcSurfaceConfigure)(WGPUSurface surface, WGPUSurfaceConfiguration const * configuration);
1367+
typedef void (*WGPUProcSurfaceUnconfigure)(WGPUSurface surface);
1368+
typedef WGPUTexture (*WGPUProcSurfaceGetCurrentTexture)(WGPUSurface surface, uint32_t * width, uint32_t * height, WGPUSurfaceStatus * status);
1369+
typedef void (*WGPUProcSurfacePresent)(WGPUSurface surface);
13611370

13621371
// Procs of Texture
13631372
typedef WGPUTextureView (*WGPUProcTextureCreateView)(WGPUTexture texture, WGPUTextureViewDescriptor const * descriptor /* nullable */);
@@ -1455,7 +1464,6 @@ WGPU_EXPORT WGPURenderPipeline wgpuDeviceCreateRenderPipeline(WGPUDevice device,
14551464
WGPU_EXPORT void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncCallback callback, void * userdata);
14561465
WGPU_EXPORT WGPUSampler wgpuDeviceCreateSampler(WGPUDevice device, WGPUSamplerDescriptor const * descriptor /* nullable */);
14571466
WGPU_EXPORT WGPUShaderModule wgpuDeviceCreateShaderModule(WGPUDevice device, WGPUShaderModuleDescriptor const * descriptor);
1458-
WGPU_EXPORT WGPUSwapChain wgpuDeviceCreateSwapChain(WGPUDevice device, WGPUSurface surface, WGPUSwapChainDescriptor const * descriptor);
14591467
WGPU_EXPORT WGPUTexture wgpuDeviceCreateTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor);
14601468
WGPU_EXPORT void wgpuDeviceDestroy(WGPUDevice device);
14611469
WGPU_EXPORT size_t wgpuDeviceEnumerateFeatures(WGPUDevice device, WGPUFeatureName * features);
@@ -1541,10 +1549,10 @@ WGPU_EXPORT void wgpuShaderModuleSetLabel(WGPUShaderModule shaderModule, char co
15411549

15421550
// Methods of Surface
15431551
WGPU_EXPORT WGPUTextureFormat wgpuSurfaceGetPreferredFormat(WGPUSurface surface, WGPUAdapter adapter);
1544-
1545-
// Methods of SwapChain
1546-
WGPU_EXPORT WGPUTextureView wgpuSwapChainGetCurrentTextureView(WGPUSwapChain swapChain);
1547-
WGPU_EXPORT void wgpuSwapChainPresent(WGPUSwapChain swapChain);
1552+
WGPU_EXPORT void wgpuSurfaceConfigure(WGPUSurface surface, WGPUSurfaceConfiguration const * configuration);
1553+
WGPU_EXPORT void wgpuSurfaceUnconfigure(WGPUSurface surface);
1554+
WGPU_EXPORT WGPUTexture wgpuSurfaceGetCurrentTexture(WGPUSurface surface, uint32_t * width, uint32_t * height, WGPUSurfaceStatus * status);
1555+
WGPU_EXPORT void wgpuSurfacePresent(WGPUSurface surface);
15481556

15491557
// Methods of Texture
15501558
WGPU_EXPORT WGPUTextureView wgpuTextureCreateView(WGPUTexture texture, WGPUTextureViewDescriptor const * descriptor /* nullable */);

0 commit comments

Comments
 (0)