Skip to content

Commit

Permalink
[WebGPU] Fix Kong pipeline creation
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Oct 5, 2023
1 parent f5b9f65 commit 69241e8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

extern WGPUDevice device;

#ifdef KINC_KONG
extern WGPUShaderModule kinc_g5_internal_webgpu_shader_module;
#endif

void kinc_g5_pipeline_init(kinc_g5_pipeline_t *pipe) {
kinc_g5_internal_pipeline_init(pipe);
}
Expand Down Expand Up @@ -183,15 +187,25 @@ void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipe) {

WGPUVertexState vsDest;
memset(&vsDest, 0, sizeof(vsDest));
#ifdef KINC_KONG
vsDest.module = kinc_g5_internal_webgpu_shader_module;
vsDest.entryPoint = pipe->vertexShader->impl.entry_name;
#else
vsDest.module = pipe->vertexShader->impl.module;
vsDest.entryPoint = "main";
#endif
vsDest.bufferCount = 1;
vsDest.buffers = &vbDesc;

WGPUFragmentState fragmentDest;
memset(&fragmentDest, 0, sizeof(fragmentDest));
#ifdef KINC_KONG
fragmentDest.module = kinc_g5_internal_webgpu_shader_module;
fragmentDest.entryPoint = pipe->fragmentShader->impl.entry_name;
#else
fragmentDest.module = pipe->fragmentShader->impl.module;
fragmentDest.entryPoint = "main";
#endif
fragmentDest.targetCount = 1;
fragmentDest.targets = &csDesc;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
extern WGPUDevice device;

#ifdef KINC_KONG
static WGPUShaderModule shader_module;
WGPUShaderModule kinc_g5_internal_webgpu_shader_module;

void kinc_g5_internal_webgpu_create_shader_module(const void *source, size_t length) {
WGPUShaderModuleWGSLDescriptor wgsl_desc = {0};
Expand All @@ -15,7 +15,7 @@ void kinc_g5_internal_webgpu_create_shader_module(const void *source, size_t len
WGPUShaderModuleDescriptor desc = {0};
desc.nextInChain = (WGPUChainedStruct *)(&wgsl_desc);

shader_module = wgpuDeviceCreateShaderModule(device, &desc);
kinc_g5_internal_webgpu_shader_module = wgpuDeviceCreateShaderModule(device, &desc);
}

void kinc_g5_shader_init(kinc_g5_shader_t *shader, const void *source, size_t length, kinc_g5_shader_type_t type) {
Expand Down

0 comments on commit 69241e8

Please sign in to comment.