d3d12: When no framebuffer attachments are present, the viewport must be clamped to framebuffer size

GL has separate no-attachment framebuffer size parameters, but
D3D uses the viewport. Clamp the viewport dimensions to lie within
GL's default framebuffer sizes.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14504>
This commit is contained in:
Jesse Natalie
2022-01-11 13:38:45 -08:00
parent 3f22038973
commit 0cc79c9c1e
2 changed files with 16 additions and 7 deletions
@@ -1356,7 +1356,9 @@ d3d12_set_framebuffer_state(struct pipe_context *pctx,
struct d3d12_context *ctx = d3d12_context(pctx);
int samples = -1;
bool prev_cbufs_or_zsbuf = ctx->fb.nr_cbufs || ctx->fb.zsbuf;
util_copy_framebuffer_state(&d3d12_context(pctx)->fb, state);
bool new_cbufs_or_zsbuf = ctx->fb.nr_cbufs || ctx->fb.zsbuf;
ctx->gfx_pipeline_state.num_cbufs = state->nr_cbufs;
ctx->gfx_pipeline_state.has_float_rtv = false;
@@ -1383,6 +1385,8 @@ d3d12_set_framebuffer_state(struct pipe_context *pctx,
ctx->gfx_pipeline_state.samples = MAX2(samples, 1);
ctx->state_dirty |= D3D12_DIRTY_FRAMEBUFFER;
if (!prev_cbufs_or_zsbuf || !new_cbufs_or_zsbuf)
ctx->state_dirty |= D3D12_DIRTY_VIEWPORT;
}
static void
+12 -7
View File
@@ -1004,16 +1004,21 @@ d3d12_draw_vbo(struct pipe_context *pctx,
}
if (ctx->cmdlist_dirty & D3D12_DIRTY_VIEWPORT) {
if (ctx->need_zero_one_depth_range) {
D3D12_VIEWPORT viewports[PIPE_MAX_VIEWPORTS];
for (unsigned i = 0; i < ctx->num_viewports; ++i) {
viewports[i] = ctx->viewports[i];
D3D12_VIEWPORT viewports[PIPE_MAX_VIEWPORTS];
for (unsigned i = 0; i < ctx->num_viewports; ++i) {
viewports[i] = ctx->viewports[i];
if (ctx->need_zero_one_depth_range) {
viewports[i].MinDepth = 0.0f;
viewports[i].MaxDepth = 1.0f;
}
ctx->cmdlist->RSSetViewports(ctx->num_viewports, viewports);
} else
ctx->cmdlist->RSSetViewports(ctx->num_viewports, ctx->viewports);
if (ctx->fb.nr_cbufs == 0 && !ctx->fb.zsbuf) {
viewports[i].TopLeftX = MAX2(0.0f, viewports[i].TopLeftX);
viewports[i].TopLeftY = MAX2(0.0f, viewports[i].TopLeftY);
viewports[i].Width = MIN2(ctx->fb.width, viewports[i].Width);
viewports[i].Height = MIN2(ctx->fb.height, viewports[i].Height);
}
}
ctx->cmdlist->RSSetViewports(ctx->num_viewports, viewports);
}
if (ctx->cmdlist_dirty & D3D12_DIRTY_SCISSOR) {