From: Marek Olšák Date: Mon, 5 Sep 2011 01:23:05 +0000 (+0200) Subject: gallium: add shadow 1D and 2D array samplers to TGSI X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d8452a0be810d7176b0cbfe6632fc0f8016b5733;p=mesa.git gallium: add shadow 1D and 2D array samplers to TGSI And filling in all the switch statements in auxiliary. Mostly untested. --- diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_info.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_info.c index 5ad32d9182c..b9a5c5c4899 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_info.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_info.c @@ -113,17 +113,23 @@ analyse_tex(struct analysis_context *ctx, case TGSI_TEXTURE_1D: readmask = TGSI_WRITEMASK_X; break; + case TGSI_TEXTURE_1D_ARRAY: case TGSI_TEXTURE_2D: case TGSI_TEXTURE_RECT: readmask = TGSI_WRITEMASK_XY; break; case TGSI_TEXTURE_SHADOW1D: + case TGSI_TEXTURE_SHADOW1D_ARRAY: case TGSI_TEXTURE_SHADOW2D: case TGSI_TEXTURE_SHADOWRECT: + case TGSI_TEXTURE_2D_ARRAY: case TGSI_TEXTURE_3D: case TGSI_TEXTURE_CUBE: readmask = TGSI_WRITEMASK_XYZ; break; + case TGSI_TEXTURE_SHADOW2D_ARRAY: + readmask = TGSI_WRITEMASK_XYZW; + break; default: assert(0); return; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index d8adb9fbfaf..602f96e4037 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -1080,17 +1080,23 @@ emit_tex( struct lp_build_tgsi_soa_context *bld, case TGSI_TEXTURE_1D: num_coords = 1; break; + case TGSI_TEXTURE_1D_ARRAY: case TGSI_TEXTURE_2D: case TGSI_TEXTURE_RECT: num_coords = 2; break; case TGSI_TEXTURE_SHADOW1D: + case TGSI_TEXTURE_SHADOW1D_ARRAY: case TGSI_TEXTURE_SHADOW2D: case TGSI_TEXTURE_SHADOWRECT: + case TGSI_TEXTURE_2D_ARRAY: case TGSI_TEXTURE_3D: case TGSI_TEXTURE_CUBE: num_coords = 3; break; + case TGSI_TEXTURE_SHADOW2D_ARRAY: + num_coords = 4; + break; default: assert(0); return; diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c index 7e2825e9ce1..64927ed6e02 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_dump.c +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c @@ -160,7 +160,9 @@ tgsi_texture_names[TGSI_TEXTURE_COUNT] = "SHADOW2D", "SHADOWRECT", "1DARRAY", - "2DARRAY" + "2DARRAY", + "SHADOW1DARRAY", + "SHADOW2DARRAY", }; const char *tgsi_property_names[TGSI_PROPERTY_COUNT] = diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index fd118c5bb11..d9de41bf826 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -1791,6 +1791,7 @@ exec_tex(struct tgsi_exec_machine *mach, break; case TGSI_TEXTURE_1D_ARRAY: + case TGSI_TEXTURE_SHADOW1D_ARRAY: FETCH(&r[0], 0, CHAN_X); FETCH(&r[1], 0, CHAN_Y); @@ -1805,6 +1806,7 @@ exec_tex(struct tgsi_exec_machine *mach, break; case TGSI_TEXTURE_2D_ARRAY: + case TGSI_TEXTURE_SHADOW2D_ARRAY: FETCH(&r[0], 0, CHAN_X); FETCH(&r[1], 0, CHAN_Y); FETCH(&r[2], 0, CHAN_Z); @@ -1884,8 +1886,10 @@ exec_txd(struct tgsi_exec_machine *mach, &r[0], &r[1], &r[2], &r[3]); /* R, G, B, A */ break; + case TGSI_TEXTURE_1D_ARRAY: case TGSI_TEXTURE_2D: case TGSI_TEXTURE_RECT: + case TGSI_TEXTURE_SHADOW1D_ARRAY: case TGSI_TEXTURE_SHADOW2D: case TGSI_TEXTURE_SHADOWRECT: @@ -1899,6 +1903,7 @@ exec_txd(struct tgsi_exec_machine *mach, &r[0], &r[1], &r[2], &r[3]); /* outputs */ break; + case TGSI_TEXTURE_2D_ARRAY: case TGSI_TEXTURE_3D: case TGSI_TEXTURE_CUBE: @@ -1912,6 +1917,19 @@ exec_txd(struct tgsi_exec_machine *mach, &r[0], &r[1], &r[2], &r[3]); break; + case TGSI_TEXTURE_SHADOW2D_ARRAY: + + FETCH(&r[0], 0, CHAN_X); + FETCH(&r[1], 0, CHAN_Y); + FETCH(&r[2], 0, CHAN_Z); + FETCH(&r[3], 0, CHAN_W); + + fetch_texel(mach->Samplers[unit], + &r[0], &r[1], &r[2], &r[3], + tgsi_sampler_lod_bias, + &r[0], &r[1], &r[2], &r[3]); + break; + default: assert(0); } @@ -1957,10 +1975,12 @@ exec_txf(struct tgsi_exec_machine *mach, switch(inst->Texture.Texture) { case TGSI_TEXTURE_3D: case TGSI_TEXTURE_2D_ARRAY: + case TGSI_TEXTURE_SHADOW2D_ARRAY: IFETCH(&r[2], 0, CHAN_Z); /* fallthrough */ case TGSI_TEXTURE_2D: case TGSI_TEXTURE_RECT: + case TGSI_TEXTURE_SHADOW1D_ARRAY: case TGSI_TEXTURE_SHADOW2D: case TGSI_TEXTURE_SHADOWRECT: case TGSI_TEXTURE_1D_ARRAY: @@ -2067,8 +2087,10 @@ exec_sample(struct tgsi_exec_machine *mach, &r[0], &r[1], &r[2], &r[3]); /* R, G, B, A */ break; + case TGSI_TEXTURE_1D_ARRAY: case TGSI_TEXTURE_2D: case TGSI_TEXTURE_RECT: + case TGSI_TEXTURE_SHADOW1D_ARRAY: case TGSI_TEXTURE_SHADOW2D: case TGSI_TEXTURE_SHADOWRECT: FETCH(&r[0], 0, CHAN_X); @@ -2087,6 +2109,7 @@ exec_sample(struct tgsi_exec_machine *mach, &r[0], &r[1], &r[2], &r[3]); /* outputs */ break; + case TGSI_TEXTURE_2D_ARRAY: case TGSI_TEXTURE_3D: case TGSI_TEXTURE_CUBE: FETCH(&r[0], 0, CHAN_X); @@ -2105,6 +2128,20 @@ exec_sample(struct tgsi_exec_machine *mach, &r[0], &r[1], &r[2], &r[3]); break; + case TGSI_TEXTURE_SHADOW2D_ARRAY: + FETCH(&r[0], 0, CHAN_X); + FETCH(&r[1], 0, CHAN_Y); + FETCH(&r[2], 0, CHAN_Z); + FETCH(&r[3], 0, CHAN_W); + + assert(modifier != TEX_MODIFIER_PROJECTED); + + fetch_texel(mach->Samplers[sampler_unit], + &r[0], &r[1], &r[2], &r[3], + control, + &r[0], &r[1], &r[2], &r[3]); + break; + default: assert(0); } diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c index 664946b00f6..5614caf63e7 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c @@ -1526,8 +1526,12 @@ emit_tex( struct x86_function *func, case TGSI_TEXTURE_3D: case TGSI_TEXTURE_CUBE: case TGSI_TEXTURE_2D_ARRAY: + case TGSI_TEXTURE_SHADOW1D_ARRAY: count = 3; break; + case TGSI_TEXTURE_SHADOW2D_ARRAY: + count = 4; + break; default: assert(0); return; diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c index 57622a0dea6..6b97803711f 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_text.c +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c @@ -826,7 +826,11 @@ static const char *texture_names[TGSI_TEXTURE_COUNT] = "RECT", "SHADOW1D", "SHADOW2D", - "SHADOWRECT" + "SHADOWRECT", + "1DARRAY", + "2DARRAY", + "SHADOW1DARRAY", + "SHADOW2DARRAY" }; static const char *type_names[] = diff --git a/src/gallium/auxiliary/tgsi/tgsi_util.c b/src/gallium/auxiliary/tgsi/tgsi_util.c index aa9a886d4a9..9f6997dc88a 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_util.c +++ b/src/gallium/auxiliary/tgsi/tgsi_util.c @@ -270,21 +270,21 @@ tgsi_util_get_inst_usage_mask(const struct tgsi_full_instruction *inst, case TGSI_TEXTURE_SHADOW1D: read_mask = TGSI_WRITEMASK_XZ; break; + case TGSI_TEXTURE_1D_ARRAY: case TGSI_TEXTURE_2D: case TGSI_TEXTURE_RECT: read_mask = TGSI_WRITEMASK_XY; break; + case TGSI_TEXTURE_SHADOW1D_ARRAY: case TGSI_TEXTURE_SHADOW2D: case TGSI_TEXTURE_SHADOWRECT: + case TGSI_TEXTURE_2D_ARRAY: case TGSI_TEXTURE_3D: case TGSI_TEXTURE_CUBE: read_mask = TGSI_WRITEMASK_XYZ; break; - case TGSI_TEXTURE_1D_ARRAY: - read_mask = TGSI_WRITEMASK_XY; - break; - case TGSI_TEXTURE_2D_ARRAY: - read_mask = TGSI_WRITEMASK_XYZ; + case TGSI_TEXTURE_SHADOW2D_ARRAY: + read_mask = TGSI_WRITEMASK_XYZW; break; default: assert(0); diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h index 72d3139562e..b9e3dcf8858 100644 --- a/src/gallium/include/pipe/p_shader_tokens.h +++ b/src/gallium/include/pipe/p_shader_tokens.h @@ -433,8 +433,10 @@ struct tgsi_instruction_label #define TGSI_TEXTURE_SHADOW2D 7 #define TGSI_TEXTURE_SHADOWRECT 8 #define TGSI_TEXTURE_1D_ARRAY 9 -#define TGSI_TEXTURE_2D_ARRAY 10 -#define TGSI_TEXTURE_COUNT 11 +#define TGSI_TEXTURE_2D_ARRAY 10 +#define TGSI_TEXTURE_SHADOW1D_ARRAY 11 +#define TGSI_TEXTURE_SHADOW2D_ARRAY 12 +#define TGSI_TEXTURE_COUNT 13 struct tgsi_instruction_texture {