diff options
author | Jason Ekstrand <jason.ekstrand@collabora.com> | 2022-11-11 15:14:16 -0600 |
---|---|---|
committer | Eric Engestrom <eric@engestrom.ch> | 2022-12-14 20:47:00 +0000 |
commit | b34f6c1559af4048e382f0bd8c394a1d26d51753 (patch) | |
tree | 88131df132795457aee91c7bdc0f8e91b728cfe7 | |
parent | 3b5c8ec1a9b31d99dd2a0192ea7d46b19c36dde8 (diff) | |
download | mesa-b34f6c1559af4048e382f0bd8c394a1d26d51753.tar.gz |
dxil: Use nir_const_value_for_uint in dxil_nir_lower_int_samplers
This change should avoid any accidental rounding issues because of
border colors getting stored in a float in dxil_wrap_sampler_state. It
also switches us to using the correct helpers for nir_const_value so we
can avoid any weird uninitialized data failures that can be caused by
filling out the fields in the struct directly.
Fixes: b9c61379ab4c ("microsoft/compiler: translate nir to dxil")
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19689>
(cherry picked from commit cd5c66e165374026d62692bcbf69a7157e460f91)
-rw-r--r-- | .pick_status.json | 2 | ||||
-rw-r--r-- | src/microsoft/compiler/dxil_nir_lower_int_samplers.c | 13 |
2 files changed, 10 insertions, 5 deletions
diff --git a/.pick_status.json b/.pick_status.json index cb024654a3b..1d4a50c2b02 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -4045,7 +4045,7 @@ "description": "dxil: Use nir_const_value_for_uint in dxil_nir_lower_int_samplers", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "b9c61379ab4c5065d624fb9403c1df9d5589b313" }, diff --git a/src/microsoft/compiler/dxil_nir_lower_int_samplers.c b/src/microsoft/compiler/dxil_nir_lower_int_samplers.c index 2faae5a07d2..fe2d33689db 100644 --- a/src/microsoft/compiler/dxil_nir_lower_int_samplers.c +++ b/src/microsoft/compiler/dxil_nir_lower_int_samplers.c @@ -217,7 +217,6 @@ static nir_ssa_def * load_bordercolor(nir_builder *b, nir_tex_instr *tex, dxil_wrap_sampler_state *active_state, const dxil_texture_swizzle_state *tex_swizzle) { - nir_const_value const_value[4] = {{0}}; int ndest_comp = nir_dest_num_components(tex->dest); unsigned swizzle[4] = { @@ -227,19 +226,25 @@ load_bordercolor(nir_builder *b, nir_tex_instr *tex, dxil_wrap_sampler_state *ac tex_swizzle->swizzle_a }; + /* Avoid any possible float conversion issues */ + uint32_t border_color[4]; + memcpy(border_color, active_state->border_color, sizeof(border_color)); + STATIC_ASSERT(sizeof(border_color) == sizeof(active_state->border_color)); + + nir_const_value const_value[4]; for (int i = 0; i < ndest_comp; ++i) { switch (swizzle[i]) { case PIPE_SWIZZLE_0: - const_value[i].f32 = 0; + const_value[i] = nir_const_value_for_uint(0, 32); break; case PIPE_SWIZZLE_1: - const_value[i].i32 = 1; + const_value[i] = nir_const_value_for_uint(1, 32); break; case PIPE_SWIZZLE_X: case PIPE_SWIZZLE_Y: case PIPE_SWIZZLE_Z: case PIPE_SWIZZLE_W: - const_value[i].f32 = active_state->border_color[swizzle[i]]; + const_value[i] = nir_const_value_for_uint(border_color[swizzle[i]], 32); break; default: unreachable("Unexpected swizzle value"); |