Skip to content

Commit c8ec006

Browse files
jdolanclaude
andcommitted
Framebuffer: sampleable resolve-depth target under MSAA
When multisampled, also create a single-sample, sampleable depth texture returned by resolveDepthTexture(), so the application can resolve the multisampled depth into it (there is no depth store-op resolve) and sample it — e.g. for soft particles. Without MSAA, resolveDepthTexture() continues to return the single-sample depth attachment directly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 8e26427 commit c8ec006

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

Sources/ObjectivelyGPU/Framebuffer.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ static bool resize(Framebuffer *self, const SDL_Size *size) {
186186
// Single-sample depth carries SAMPLER so it can be read directly via
187187
// resolveDepthTexture (e.g. soft particles). Multisampled depth is a plain
188188
// depth-stencil target; sampling it requires the separate resolveDepthTexture,
189-
// populated by a resolve pass (SDL has no depth store-op resolve) — TODO when MSAA lands.
189+
// a single-sample sampleable target the app populates with a resolve pass
190+
// (SDL has no depth store-op resolve).
190191
self->depthTexture = $(self->device, createTexture, &(SDL_GPUTextureCreateInfo) {
191192
.type = SDL_GPU_TEXTURETYPE_2D,
192193
.format = self->depthFormat,
@@ -197,6 +198,19 @@ static bool resize(Framebuffer *self, const SDL_Size *size) {
197198
.num_levels = 1,
198199
.sample_count = self->sampleCount,
199200
}, NULL);
201+
202+
if (multisampled) {
203+
self->resolveDepthTexture = $(self->device, createTexture, &(SDL_GPUTextureCreateInfo) {
204+
.type = SDL_GPU_TEXTURETYPE_2D,
205+
.format = self->depthFormat,
206+
.usage = SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER,
207+
.width = (Uint32) self->size.w,
208+
.height = (Uint32) self->size.h,
209+
.layer_count_or_depth = 1,
210+
.num_levels = 1,
211+
.sample_count = SDL_GPU_SAMPLECOUNT_1,
212+
}, NULL);
213+
}
200214
}
201215

202216
return true;

0 commit comments

Comments
 (0)