return imm;
}
-/**
- * Return the dimension of the texture coordinates, as well as the location of
- * the shadow reference value or the sample index.
- */
-static inline int
-toy_tgsi_get_texture_coord_dim(int tgsi_tex, int *shadow_or_sample)
-{
- int dim;
-
- /*
- * Depending on the texture target, (src0, src1.x) is interpreted
- * differently:
- *
- * (s, *, *, *, *), for 1D
- * (s, t, *, *, *), for 2D, RECT
- * (s, t, r, *, *), for 3D, CUBE
- *
- * (s, layer, *, *, *), for 1D_ARRAY
- * (s, t, layer, *, *), for 2D_ARRAY
- * (s, t, r, layer, *), for CUBE_ARRAY
- *
- * (s, *, shadow, *, *), for SHADOW1D
- * (s, t, shadow, *, *), for SHADOW2D, SHADOWRECT
- * (s, t, r, shadow, *), for SHADOWCUBE
- *
- * (s, layer, shadow, *, *), for SHADOW1D_ARRAY
- * (s, t, layer, shadow, *), for SHADOW2D_ARRAY
- * (s, t, r, layer, shadow), for SHADOWCUBE_ARRAY
- *
- * (s, t, sample, *, *), for 2D_MSAA
- * (s, t, layer, sample, *), for 2D_ARRAY_MSAA
- */
- switch (tgsi_tex) {
- case TGSI_TEXTURE_1D:
- case TGSI_TEXTURE_SHADOW1D:
- dim = 1;
- break;
- case TGSI_TEXTURE_2D:
- case TGSI_TEXTURE_RECT:
- case TGSI_TEXTURE_1D_ARRAY:
- case TGSI_TEXTURE_SHADOW2D:
- case TGSI_TEXTURE_SHADOWRECT:
- case TGSI_TEXTURE_SHADOW1D_ARRAY:
- case TGSI_TEXTURE_2D_MSAA:
- dim = 2;
- break;
- case TGSI_TEXTURE_3D:
- case TGSI_TEXTURE_CUBE:
- case TGSI_TEXTURE_2D_ARRAY:
- case TGSI_TEXTURE_SHADOWCUBE:
- case TGSI_TEXTURE_SHADOW2D_ARRAY:
- case TGSI_TEXTURE_2D_ARRAY_MSAA:
- dim = 3;
- break;
- case TGSI_TEXTURE_CUBE_ARRAY:
- case TGSI_TEXTURE_SHADOWCUBE_ARRAY:
- dim = 4;
- break;
- default:
- assert(!"unknown texture target");
- dim = 0;
- break;
- }
-
- if (shadow_or_sample) {
- switch (tgsi_tex) {
- case TGSI_TEXTURE_SHADOW1D:
- /* there is a gap */
- *shadow_or_sample = 2;
- break;
- case TGSI_TEXTURE_SHADOW2D:
- case TGSI_TEXTURE_SHADOWRECT:
- case TGSI_TEXTURE_SHADOWCUBE:
- case TGSI_TEXTURE_SHADOW1D_ARRAY:
- case TGSI_TEXTURE_SHADOW2D_ARRAY:
- case TGSI_TEXTURE_SHADOWCUBE_ARRAY:
- case TGSI_TEXTURE_2D_MSAA:
- case TGSI_TEXTURE_2D_ARRAY_MSAA:
- *shadow_or_sample = dim;
- break;
- default:
- /* no shadow nor sample */
- *shadow_or_sample = -1;
- break;
- }
- }
-
- return dim;
-}
-
void
toy_compiler_translate_tgsi(struct toy_compiler *tc,
const struct tgsi_token *tokens, bool aos,