From a5f44cc8c2ce0916809ce5da5a2490ad000ef099 Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Tue, 1 May 2012 02:38:51 +0200 Subject: gallium/tgsi: Split sampler views from shader resources. This commit splits the current concept of resource into "sampler views" and "shader resources": "Sampler views" are textures or buffers that are bound to a given shader stage and can be read from in conjunction with a sampler object. They are analogous to OpenGL texture objects or Direct3D SRVs. "Shader resources" are textures or buffers that can be read and written from a shader. There's no support for floating point coordinates, address wrap modes or filtering, and, unlike sampler views, shader resources are global for the whole graphics pipeline. They are analogous to OpenGL image objects (as in ARB_shader_image_load_store) or Direct3D UAVs. Most hardware is likely to implement shader resources and sampler views as separate objects, so, having the distinction at the API level simplifies things slightly for the driver. This patch introduces the SVIEW register file with a declaration token and syntax analogous to the already existing RES register file. After this change, the SAMPLE_* opcodes no longer accept a resource as input, but rather a SVIEW object. To preserve the functionality of reading from a sampler view with integer coordinates, the SAMPLE_I(_MS) opcodes are introduced which are similar to LOAD(_MS) but take a SVIEW register instead of a RES register as argument. --- src/gallium/auxiliary/tgsi/tgsi_text.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'src/gallium/auxiliary/tgsi/tgsi_text.c') diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c index 4b3d22c3072..cec9cd36a55 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_text.c +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c @@ -1066,6 +1066,22 @@ static boolean parse_declaration( struct translate_ctx *ctx ) report_error(ctx, "Expected texture target"); return FALSE; } + + ctx->cur = cur; + + } else if (file == TGSI_FILE_SAMPLER_VIEW) { + for (i = 0; i < TGSI_TEXTURE_COUNT; i++) { + if (str_match_no_case(&cur, tgsi_texture_names[i])) { + if (!is_digit_alpha_underscore(cur)) { + decl.SamplerView.Resource = i; + break; + } + } + } + if (i == TGSI_TEXTURE_COUNT) { + report_error(ctx, "Expected texture target"); + return FALSE; + } eat_opt_white( &cur ); if (*cur != ',') { report_error( ctx, "Expected `,'" ); @@ -1079,16 +1095,16 @@ static boolean parse_declaration( struct translate_ctx *ctx ) if (!is_digit_alpha_underscore(cur)) { switch (j) { case 0: - decl.Resource.ReturnTypeX = i; + decl.SamplerView.ReturnTypeX = i; break; case 1: - decl.Resource.ReturnTypeY = i; + decl.SamplerView.ReturnTypeY = i; break; case 2: - decl.Resource.ReturnTypeZ = i; + decl.SamplerView.ReturnTypeZ = i; break; case 3: - decl.Resource.ReturnTypeW = i; + decl.SamplerView.ReturnTypeW = i; break; default: assert(0); @@ -1116,10 +1132,10 @@ static boolean parse_declaration( struct translate_ctx *ctx ) } } if (j < 4) { - decl.Resource.ReturnTypeY = - decl.Resource.ReturnTypeZ = - decl.Resource.ReturnTypeW = - decl.Resource.ReturnTypeX; + decl.SamplerView.ReturnTypeY = + decl.SamplerView.ReturnTypeZ = + decl.SamplerView.ReturnTypeW = + decl.SamplerView.ReturnTypeX; } ctx->cur = cur; } else { -- cgit v1.2.3