From fcc41b063140bb342d51e0e93bf490488fc0e626 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Tue, 29 Jun 2021 21:01:19 -0700 Subject: [PATCH] i915g: Set up the cube map texture wrap modes. There are HW limits on what you're allowed to do. No change on dEQP, but one less thing for me to worry about with our busted cubes. Part-of: --- src/gallium/drivers/i915/i915_state_sampler.c | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/gallium/drivers/i915/i915_state_sampler.c b/src/gallium/drivers/i915/i915_state_sampler.c index 11efa05d54a..4879a7b8fd1 100644 --- a/src/gallium/drivers/i915/i915_state_sampler.c +++ b/src/gallium/drivers/i915/i915_state_sampler.c @@ -89,6 +89,30 @@ update_sampler(struct i915_context *i915, uint32_t unit, state[0] |= SS2_REVERSE_GAMMA_ENABLE; } + /* The GLES2 spec says textures are incomplete (return 0,0,0,1) if: + * + * "A cube map sampler is called, any of the corresponding texture images are + * non-power-of-two images, and either the texture wrap mode is not + * CLAMP_TO_EDGE, or the minification filter is neither NEAREST nor LINEAR." + * + * while the i915 spec says: + * + * "When using cube map texture coordinates, only TEXCOORDMODE_CLAMP and * + * TEXCOORDMODE_CUBE settings are valid, and each TC component must have the + * same Address Control mode. TEXCOORDMODE_CUBE is not valid unless the + * width and height of the cube map are power-of-2." + * + * We don't expose support for the seamless cube map extension, so always use + * edge clamping. + */ + if (pt->target == PIPE_TEXTURE_CUBE) { + state[1] &= ~(SS3_TCX_ADDR_MODE_MASK | SS3_TCY_ADDR_MODE_MASK | + SS3_TCZ_ADDR_MODE_MASK); + state[1] |= (TEXCOORDMODE_CLAMP_EDGE << SS3_TCX_ADDR_MODE_SHIFT); + state[1] |= (TEXCOORDMODE_CLAMP_EDGE << SS3_TCY_ADDR_MODE_SHIFT); + state[1] |= (TEXCOORDMODE_CLAMP_EDGE << SS3_TCZ_ADDR_MODE_SHIFT); + } + /* 3D textures don't seem to respect the border color. * Fallback if there's ever a danger that they might refer to * it.