2626#include <SDL3/SDL_gpu.h>
2727
2828#include <Objectively/Object.h>
29+ #include <Objectively/Resource.h>
2930
3031#include <ObjectivelyGPU/Types.h>
3132
@@ -87,7 +88,7 @@ struct ComputePipelineInterface {
8788 * @brief Initializes this ComputePipeline from a fully-populated `SDL_GPUComputePipelineCreateInfo`.
8889 * @details This is the designated initializer. All fields of @p info, including
8990 * `code`, `code_size`, and `format`, must be set by the caller. Prefer
90- * `initWithResource ` to load a compiled blob from the Resource system with
91+ * `initWithResourceName ` to load a compiled blob from the Resource system with
9192 * automatic format selection.
9293 * @param self The ComputePipeline.
9394 * @param device The RenderDevice used to create and release the pipeline. Retained.
@@ -98,24 +99,42 @@ struct ComputePipelineInterface {
9899 ComputePipeline * (* initWithDevice )(ComputePipeline * self , RenderDevice * device , const SDL_GPUComputePipelineCreateInfo * info );
99100
100101 /**
101- * @fn ComputePipeline *ComputePipeline::initWithResource(ComputePipeline *self, RenderDevice *device, const char *name, const SDL_GPUComputePipelineCreateInfo *info)
102+ * @fn ComputePipeline *ComputePipeline::initWithResource(ComputePipeline *self, RenderDevice *device, const Resource *resource, SDL_GPUShaderFormat format, const SDL_GPUComputePipelineCreateInfo *info)
103+ * @brief Initializes this ComputePipeline from an already-loaded compiled blob.
104+ * @details Uses @p resource's data as the pipeline `code` for the given @p format.
105+ * `entrypoint` defaults to `main0` (MSL) or `main` when not set; the `code`,
106+ * `code_size`, and `format` fields of @p info are ignored. `initWithResourceName`
107+ * resolves a name to a resource and format, then delegates here.
108+ * @param self The ComputePipeline.
109+ * @param device The RenderDevice used to create and release the pipeline. Retained.
110+ * @param resource The loaded shader blob; must have non-empty data.
111+ * @param format The shader format of @p resource's data.
112+ * @param info Compute pipeline creation parameters; `code`, `code_size`, and `format` are ignored.
113+ * @return The initialized ComputePipeline, or `NULL` on failure.
114+ * @memberof ComputePipeline
115+ */
116+ ComputePipeline * (* initWithResource )(ComputePipeline * self , RenderDevice * device , const Resource * resource , SDL_GPUShaderFormat format , const SDL_GPUComputePipelineCreateInfo * info );
117+
118+ /**
119+ * @fn ComputePipeline *ComputePipeline::initWithResourceName(ComputePipeline *self, RenderDevice *device, const char *name, const SDL_GPUComputePipelineCreateInfo *info)
102120 * @brief Initializes this ComputePipeline from a compiled blob loaded via the Resource system.
103121 * @details Appends the platform-appropriate extension to @p name and resolves it via
104122 * Objectively's ResourceProvider chain:
105123 * - Metal (macOS/iOS): `.metal`
106124 * - Vulkan (Linux/Android): `.spv`
107125 * - D3D12 (Windows): `.dxil`
108- * The caller fills in @c entrypoint, thread counts, and binding counts in @p info;
109- * `code`, `code_size`, and `format` are filled in here. Shader blobs are produced
110- * offline by @c sdl-shadercross.
126+ * The first supported, resolvable, non-empty blob is selected and passed to
127+ * `initWithResource` with its format. The caller fills in @c entrypoint, thread
128+ * counts, and binding counts in @p info; `code`, `code_size`, `format`, and a default
129+ * `entrypoint` are supplied. Shader blobs are produced offline by @c sdl-shadercross.
111130 * @param self The ComputePipeline.
112131 * @param device The RenderDevice used to create and release the pipeline. Retained.
113132 * @param name Shader base name without extension, e.g. @c "HelloCompute.comp".
114133 * @param info Compute pipeline creation parameters; `code`, `code_size`, and `format` are ignored.
115134 * @return The initialized ComputePipeline. GPU_Asserts if no supported blob is found.
116135 * @memberof ComputePipeline
117136 */
118- ComputePipeline * (* initWithResource )(ComputePipeline * self , RenderDevice * device , const char * name , const SDL_GPUComputePipelineCreateInfo * info );
137+ ComputePipeline * (* initWithResourceName )(ComputePipeline * self , RenderDevice * device , const char * name , const SDL_GPUComputePipelineCreateInfo * info );
119138};
120139
121140/**
0 commit comments