ilo: use tgsi_util_get_texture_coord_dim()

And remove toy_tgsi_get_texture_coord_dim().
This commit is contained in:
Chia-I Wu 2013-05-08 11:07:27 +08:00
parent 75a48a53d8
commit b74af51a46
3 changed files with 4 additions and 92 deletions

View file

@ -26,6 +26,7 @@
*/ */
#include "tgsi/tgsi_dump.h" #include "tgsi/tgsi_dump.h"
#include "tgsi/tgsi_util.h"
#include "toy_compiler.h" #include "toy_compiler.h"
#include "toy_tgsi.h" #include "toy_tgsi.h"
#include "toy_legalize.h" #include "toy_legalize.h"
@ -605,7 +606,7 @@ fs_prepare_tgsi_sampling(struct toy_compiler *tc, const struct toy_inst *inst,
break; break;
} }
num_coords = toy_tgsi_get_texture_coord_dim(inst->tex.target, &ref_pos); num_coords = tgsi_util_get_texture_coord_dim(inst->tex.target, &ref_pos);
tsrc_transpose(inst->src[0], coords); tsrc_transpose(inst->src[0], coords);
bias_or_lod = tsrc_null(); bias_or_lod = tsrc_null();
ref_or_si = tsrc_null(); ref_or_si = tsrc_null();

View file

@ -26,6 +26,7 @@
*/ */
#include "tgsi/tgsi_dump.h" #include "tgsi/tgsi_dump.h"
#include "tgsi/tgsi_util.h"
#include "toy_compiler.h" #include "toy_compiler.h"
#include "toy_tgsi.h" #include "toy_tgsi.h"
#include "toy_legalize.h" #include "toy_legalize.h"
@ -377,7 +378,7 @@ vs_prepare_tgsi_sampling(struct toy_compiler *tc, const struct toy_inst *inst,
num_derivs = 0; num_derivs = 0;
sampler_src = 1; sampler_src = 1;
num_coords = toy_tgsi_get_texture_coord_dim(inst->tex.target, &ref_pos); num_coords = tgsi_util_get_texture_coord_dim(inst->tex.target, &ref_pos);
/* extract the parameters */ /* extract the parameters */
switch (inst->opcode) { switch (inst->opcode) {

View file

@ -145,96 +145,6 @@ toy_tgsi_get_imm(const struct toy_tgsi *tgsi, unsigned index,
return imm; 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 void
toy_compiler_translate_tgsi(struct toy_compiler *tc, toy_compiler_translate_tgsi(struct toy_compiler *tc,
const struct tgsi_token *tokens, bool aos, const struct tgsi_token *tokens, bool aos,