Skip to content

Commit 0ec94be

Browse files
committed
Log shader compilation and pipeline assembly via SDL_Log
RenderDevice::loadShader/loadComputePipeline now announce the resolved asset name, format, and key shader-stage counts (samplers, uniform/storage buffers, thread counts) before compiling. GraphicsPipeline and ComputePipeline's initWithDevice log a summary of the pipeline being assembled (color targets, MSAA, depth; or compute thread/resource counts) -- these have no name to log by that point, so this describes their shape instead. Requested to make it easier to tell what's happening during renderer bring-up (which shader is compiling, which pipeline is being built) without reaching for a debugger.
1 parent a292d43 commit 0ec94be

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

Sources/ObjectivelyGPU/ComputePipeline.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ static ComputePipeline *initWithDevice(ComputePipeline *self, RenderDevice *devi
6060
if (self) {
6161
self->device = retain(device);
6262

63+
SDL_Log("Assembling ComputePipeline (threads %ux%ux%u, %u samplers, %u storage textures, %u storage buffers)",
64+
info->threadcount_x, info->threadcount_y, info->threadcount_z,
65+
info->num_samplers,
66+
info->num_readonly_storage_textures + info->num_readwrite_storage_textures,
67+
info->num_readonly_storage_buffers + info->num_readwrite_storage_buffers);
68+
6369
self->pipeline = SDL_CreateGPUComputePipeline(device->device, info);
6470
GPU_Assert(self->pipeline, "SDL_CreateGPUComputePipeline");
6571
}

Sources/ObjectivelyGPU/GraphicsPipeline.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ static GraphicsPipeline *initWithDevice(GraphicsPipeline *self, RenderDevice *de
127127

128128
self->device = retain(device);
129129

130+
SDL_Log("Assembling GraphicsPipeline (%u color targets, %ux MSAA, %s)",
131+
info->target_info.num_color_targets,
132+
info->multisample_state.sample_count == SDL_GPU_SAMPLECOUNT_1 ? 1 :
133+
info->multisample_state.sample_count == SDL_GPU_SAMPLECOUNT_2 ? 2 :
134+
info->multisample_state.sample_count == SDL_GPU_SAMPLECOUNT_4 ? 4 : 8,
135+
info->target_info.has_depth_stencil_target ? "depth" : "no depth");
136+
130137
self->pipeline = SDL_CreateGPUGraphicsPipeline(device->device, info);
131138
GPU_Assert(self->pipeline, "SDL_CreateGPUGraphicsPipeline");
132139
}

Sources/ObjectivelyGPU/RenderDevice.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,18 @@ static Shader *loadShader(RenderDevice *self, const char *name, const SDL_GPUSha
355355

356356
GPU_ShaderFormat resolved;
357357
Resource *resource = resolveShaderResource(name, self->shaderFormats, &resolved);
358-
358+
359+
SDL_Log("Compiling shader \"%s%s\" (%s, %u samplers, %u uniform buffers, %u storage buffers)",
360+
name, resolved.ext,
361+
info->stage == SDL_GPU_SHADERSTAGE_VERTEX ? "vertex" : "fragment",
362+
info->num_samplers, info->num_uniform_buffers, info->num_storage_buffers);
363+
359364
SDL_GPUShaderCreateInfo create = *info;
360-
365+
361366
create.code = resource->data->bytes;
362367
create.code_size = resource->data->length;
363368
create.format = resolved.format;
364-
369+
365370
if (!create.entrypoint) {
366371
switch (create.stage) {
367372
case SDL_GPU_SHADERSTAGE_VERTEX:
@@ -388,6 +393,10 @@ static ComputePipeline *loadComputePipeline(RenderDevice *self, const char *name
388393
GPU_ShaderFormat resolved;
389394
Resource *resource = resolveShaderResource(name, self->shaderFormats, &resolved);
390395

396+
SDL_Log("Compiling compute pipeline \"%s%s\" (threads %ux%ux%u)",
397+
name, resolved.ext,
398+
info->threadcount_x, info->threadcount_y, info->threadcount_z);
399+
391400
SDL_GPUComputePipelineCreateInfo create = *info;
392401
create.code = resource->data->bytes;
393402
create.code_size = resource->data->length;

0 commit comments

Comments
 (0)