Skip to content

Commit 991eaec

Browse files
committed
Assign default bind group entries(yay fixes crash)
1 parent 89ec82f commit 991eaec

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/backend_wgpu.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,20 @@ void UpdateBindGroup(DescribedBindGroup *bg) {
671671
to->size = from->size;
672672
to->sampler = from->sampler;
673673
to->textureView = from->textureView;
674+
675+
if(bg->layout && bg->layout->entries){
676+
if(to->sampler == NULL && bg->layout->entries[i].type == texture_sampler){
677+
to->sampler = (WGPUSampler)g_renderstate.defaultSampler.sampler;
678+
}
679+
if(to->textureView == NULL && bg->layout->entries[i].type == texture2d){
680+
to->textureView = (WGPUTextureView)g_renderstate.whitePixel.view;
681+
}
682+
if(to->buffer == NULL && (bg->layout->entries[i].type == uniform_buffer || bg->layout->entries[i].type == storage_buffer)){
683+
to->buffer = (WGPUBuffer)g_renderstate.identityMatrix->buffer;
684+
to->offset = 0;
685+
to->size = 64; // sizeof(Matrix)
686+
}
687+
}
674688
}
675689

676690
desc.entries = aswgpu;

0 commit comments

Comments
 (0)