mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-09 12:40:23 +01:00
asahi: Clamp 8-bit integer RTs
Fixes gl-3.0-render-integer. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26056>
This commit is contained in:
parent
8d9d9d0207
commit
019a52fff0
1 changed files with 20 additions and 0 deletions
|
|
@ -3,8 +3,10 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "compiler/agx_internal_formats.h"
|
||||
#include "compiler/glsl_types.h"
|
||||
#include "util/format/u_format.h"
|
||||
#include "util/macros.h"
|
||||
#include "agx_nir_format_helpers.h"
|
||||
#include "agx_pack.h"
|
||||
|
|
@ -57,6 +59,24 @@ store_tilebuffer(nir_builder *b, struct agx_tilebuffer_layout *tib,
|
|||
value = nir_f2f32(b, value);
|
||||
}
|
||||
|
||||
/* 8-bit formats must be clamped in software, so do so on store. Piglit
|
||||
* gl-3.0-render-integer checks this.
|
||||
*/
|
||||
const struct util_format_description *desc = util_format_description(format);
|
||||
unsigned c = util_format_get_first_non_void_channel(format);
|
||||
|
||||
if (desc->channel[c].size == 8 && util_format_is_pure_integer(format)) {
|
||||
assert(desc->is_array);
|
||||
|
||||
value = nir_u2u16(b, value);
|
||||
if (util_format_is_pure_sint(logical_format)) {
|
||||
value = nir_iclamp(b, value, nir_imm_intN_t(b, INT8_MIN, 16),
|
||||
nir_imm_intN_t(b, INT8_MAX, 16));
|
||||
} else {
|
||||
value = nir_umin(b, value, nir_imm_intN_t(b, UINT8_MAX, 16));
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t offset_B = agx_tilebuffer_offset_B(tib, rt);
|
||||
nir_store_local_pixel_agx(b, value, nir_imm_intN_t(b, ALL_SAMPLES, 16),
|
||||
.base = offset_B, .write_mask = write_mask,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue