d3d12: Add a fallback for int clears where value can't be cast to float

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26104>
This commit is contained in:
Jesse Natalie 2023-11-07 09:05:39 -08:00 committed by Marge Bot
parent a07bdf0152
commit a3899c4530
2 changed files with 51 additions and 14 deletions

View file

@ -32,7 +32,6 @@ spec@!opengl 3.2@gl-3.2-adj-prims line cull-back pv-last,Fail
spec@!opengl 3.2@gl-3.2-adj-prims line cull-front pv-last,Fail
spec@!opengl 3.2@gl-3.2-adj-prims pv-last,Fail
spec@arb_draw_indirect@arb_draw_indirect-api-errors,Crash
spec@arb_clear_texture@arb_clear_texture-integer,Fail
spec@arb_explicit_attrib_location@overlapping-locations-input-attribs api,Crash
spec@arb_explicit_attrib_location@overlapping-locations-input-attribs shader,Crash
spec@arb_framebuffer_object@fbo-blit-scaled-linear,Fail
@ -166,8 +165,6 @@ spec@ext_framebuffer_multisample@sample-alpha-to-one 2,Fail
spec@ext_framebuffer_multisample@sample-alpha-to-one 4,Fail
spec@ext_framebuffer_multisample@sample-alpha-to-one 6,Fail
spec@ext_framebuffer_multisample@sample-alpha-to-one 8,Fail
spec@ext_texture_integer@fbo_integer_precision_clear,Fail
spec@ext_texture_integer@fbo_integer_readpixels_sint_uint,Fail
spec@ext_texture_integer@texwrap formats,Fail
spec@ext_texture_integer@texwrap formats offset,Fail
spec@ext_texture_integer@texwrap formats offset@GL_ALPHA16I_EXT,Fail

View file

@ -2044,29 +2044,69 @@ d3d12_clear_render_target(struct pipe_context *pctx,
D3D12_TRANSITION_FLAG_INVALIDATE_BINDINGS);
d3d12_apply_resource_states(ctx, false);
enum pipe_format format = psurf->texture->format;
enum pipe_format format = psurf->format;
float clear_color[4];
bool clear_fallback = false;
if (util_format_is_pure_uint(format)) {
for (int c = 0; c < 4; ++c)
for (int c = 0; c < 4 && !clear_fallback; ++c) {
clear_color[c] = color->ui[c];
clear_fallback = (uint32_t)clear_color[c] != color->ui[c];
}
} else if (util_format_is_pure_sint(format)) {
for (int c = 0; c < 4; ++c)
for (int c = 0; c < 4 && !clear_fallback; ++c) {
clear_color[c] = color->i[c];
clear_fallback = (int32_t)clear_color[c] != color->i[c];
}
} else {
for (int c = 0; c < 4; ++c)
clear_color[c] = color->f[c];
}
if (!(util_format_colormask(util_format_description(psurf->texture->format)) &
PIPE_MASK_A))
clear_color[3] = 1.0f;
if (clear_fallback) {
util_blitter_save_blend(ctx->blitter, ctx->gfx_pipeline_state.blend);
util_blitter_save_depth_stencil_alpha(ctx->blitter, ctx->gfx_pipeline_state.zsa);
util_blitter_save_vertex_elements(ctx->blitter, ctx->gfx_pipeline_state.ves);
util_blitter_save_stencil_ref(ctx->blitter, &ctx->stencil_ref);
util_blitter_save_rasterizer(ctx->blitter, ctx->gfx_pipeline_state.rast);
util_blitter_save_fragment_shader(ctx->blitter, ctx->gfx_stages[PIPE_SHADER_FRAGMENT]);
util_blitter_save_vertex_shader(ctx->blitter, ctx->gfx_stages[PIPE_SHADER_VERTEX]);
util_blitter_save_geometry_shader(ctx->blitter, ctx->gfx_stages[PIPE_SHADER_GEOMETRY]);
util_blitter_save_tessctrl_shader(ctx->blitter, ctx->gfx_stages[PIPE_SHADER_TESS_CTRL]);
util_blitter_save_tesseval_shader(ctx->blitter, ctx->gfx_stages[PIPE_SHADER_TESS_EVAL]);
D3D12_RECT rect = { (int)dstx, (int)dsty,
(int)dstx + (int)width,
(int)dsty + (int)height };
ctx->cmdlist->ClearRenderTargetView(surf->desc_handle.cpu_handle,
clear_color, 1, &rect);
util_blitter_save_framebuffer(ctx->blitter, &ctx->fb);
util_blitter_save_viewport(ctx->blitter, ctx->viewport_states);
util_blitter_save_scissor(ctx->blitter, ctx->scissor_states);
util_blitter_save_fragment_sampler_states(ctx->blitter,
ctx->num_samplers[PIPE_SHADER_FRAGMENT],
(void **)ctx->samplers[PIPE_SHADER_FRAGMENT]);
util_blitter_save_fragment_sampler_views(ctx->blitter,
ctx->num_sampler_views[PIPE_SHADER_FRAGMENT],
ctx->sampler_views[PIPE_SHADER_FRAGMENT]);
util_blitter_save_fragment_constant_buffer_slot(ctx->blitter, ctx->cbufs[PIPE_SHADER_FRAGMENT]);
util_blitter_save_vertex_buffer_slot(ctx->blitter, ctx->vbs);
util_blitter_save_sample_mask(ctx->blitter, ctx->gfx_pipeline_state.sample_mask, 0);
util_blitter_save_so_targets(ctx->blitter, ctx->gfx_pipeline_state.num_so_targets, ctx->so_targets);
union pipe_color_union local_color;
memcpy(&local_color, color, sizeof(local_color));
if (!(util_format_colormask(util_format_description(psurf->format)) & PIPE_MASK_A)) {
assert(!util_format_is_float(psurf->format));
local_color.ui[3] = 1;
}
util_blitter_clear_render_target(ctx->blitter, psurf, &local_color, dstx, dsty, width, height);
} else {
if (!(util_format_colormask(util_format_description(psurf->format)) &
PIPE_MASK_A))
clear_color[3] = 1.0f;
D3D12_RECT rect = { (int)dstx, (int)dsty,
(int)dstx + (int)width,
(int)dsty + (int)height };
ctx->cmdlist->ClearRenderTargetView(surf->desc_handle.cpu_handle,
clear_color, 1, &rect);
}
d3d12_batch_reference_surface_texture(d3d12_current_batch(ctx), surf);