Skip to content

Commit d49e2cd

Browse files
jdolanclaude
andcommitted
Revert the MSAA resolve-depth attachment changes
SDL_gpu cannot sample a multisample texture, so the sampleable multisampled depth and its single-sample resolve target could never work. The consuming application instead writes a single-sample float depth copy to a color attachment (which does resolve), so these changes are unnecessary. Reverts to the resolveColorTexture / single-sample sampleable-depth baseline. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 0401f7b commit d49e2cd

1 file changed

Lines changed: 5 additions & 19 deletions

File tree

Sources/ObjectivelyGPU/Framebuffer.c

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -183,34 +183,20 @@ static bool resize(Framebuffer *self, const SDL_Size *size) {
183183

184184
if (self->depthFormat != SDL_GPU_TEXTUREFORMAT_INVALID) {
185185

186-
// Depth carries SAMPLER so it can be read in a shader. Single-sample depth is
187-
// read directly via resolveDepthTexture (e.g. soft particles). Multisampled
188-
// depth is read (as a multisample texture) by an app resolve pass that writes
189-
// the separate single-sample resolveDepthTexture, since SDL has no depth
190-
// store-op resolve.
186+
// Single-sample depth carries SAMPLER so it can be read directly via
187+
// resolveDepthTexture (e.g. soft particles). Multisampled depth is a plain
188+
// 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.
191190
self->depthTexture = $(self->device, createTexture, &(SDL_GPUTextureCreateInfo) {
192191
.type = SDL_GPU_TEXTURETYPE_2D,
193192
.format = self->depthFormat,
194-
.usage = SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER,
193+
.usage = SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET | (multisampled ? 0 : SDL_GPU_TEXTUREUSAGE_SAMPLER),
195194
.width = (Uint32) self->size.w,
196195
.height = (Uint32) self->size.h,
197196
.layer_count_or_depth = 1,
198197
.num_levels = 1,
199198
.sample_count = self->sampleCount,
200199
}, 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-
}
214200
}
215201

216202
return true;

0 commit comments

Comments
 (0)