summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2017-12-05 20:41:55 -0700
committerBrian Paul <[email protected]>2018-09-10 13:07:30 -0600
commit6b039c7d7cb2807a1b16c892b78f5f4ad65c8947 (patch)
tree06c504f1907061dabe2aa7d2df59d762e88db8d5
parentcf2fb6813c97594e2cc64100b8262de259d9ff1a (diff)
svga: check number of samples before emitting MSAA decls/opcodes
If real MSAA is not available, we only support 1 sample/pixel. In that case, we must not declare MSAA resources or emit MSAA opcodes. Do that by checking the sample count. Fixes several piglit MSAA tests, such as arb_texture_multisample-sample-depth (when the hard-coded sample count of 4 is fixed in that test). Reviewed-by: Charmaine Lee <[email protected]>
-rw-r--r--src/gallium/drivers/svga/svga_tgsi_vgpu10.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
index 87669618319..aa07ee1ace9 100644
--- a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
+++ b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
@@ -3160,12 +3160,20 @@ emit_sampler_declarations(struct svga_shader_emitter_v10 *emit)
/**
- * Translate TGSI_TEXTURE_x to VGAPU10_RESOURCE_DIMENSION_x.
+ * Translate TGSI_TEXTURE_x to VGPU10_RESOURCE_DIMENSION_x.
*/
static unsigned
tgsi_texture_to_resource_dimension(enum tgsi_texture_type target,
+ unsigned num_samples,
boolean is_array)
{
+ if (target == TGSI_TEXTURE_2D_MSAA && num_samples < 2) {
+ target = TGSI_TEXTURE_2D;
+ }
+ else if (target == TGSI_TEXTURE_2D_ARRAY_MSAA && num_samples < 2) {
+ target = TGSI_TEXTURE_2D_ARRAY;
+ }
+
switch (target) {
case TGSI_TEXTURE_BUFFER:
return VGPU10_RESOURCE_DIMENSION_BUFFER;
@@ -3252,6 +3260,7 @@ emit_resource_declarations(struct svga_shader_emitter_v10 *emit)
opcode0.opcodeType = VGPU10_OPCODE_DCL_RESOURCE;
opcode0.resourceDimension =
tgsi_texture_to_resource_dimension(emit->sampler_target[i],
+ emit->key.tex[i].num_samples,
emit->key.tex[i].is_array);
opcode0.sampleCount = emit->key.tex[i].num_samples;
operand0.value = 0;
@@ -5529,7 +5538,8 @@ emit_txf(struct svga_shader_emitter_v10 *emit,
const struct tgsi_full_instruction *inst)
{
const uint unit = inst->Src[1].Register.Index;
- const boolean msaa = tgsi_is_msaa_target(inst->Texture.Texture);
+ const boolean msaa = tgsi_is_msaa_target(inst->Texture.Texture)
+ && emit->key.tex[unit].num_samples > 1;
int offsets[3];
struct tex_swizzle_info swz_info;
@@ -5538,6 +5548,8 @@ emit_txf(struct svga_shader_emitter_v10 *emit,
get_texel_offsets(emit, inst, offsets);
if (msaa) {
+ assert(emit->key.tex[unit].num_samples > 1);
+
/* Fetch one sample from an MSAA texture */
struct tgsi_full_src_register sampleIndex =
scalar_src(&inst->Src[0], TGSI_SWIZZLE_W);