summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/tgsi/tgsi_build.c
diff options
context:
space:
mode:
authorFrancisco Jerez <[email protected]>2012-05-01 02:38:51 +0200
committerFrancisco Jerez <[email protected]>2012-05-11 12:39:39 +0200
commita5f44cc8c2ce0916809ce5da5a2490ad000ef099 (patch)
tree33ffba4161f7f3201a505ab5a23d6f70ea6cfc7f /src/gallium/auxiliary/tgsi/tgsi_build.c
parentd9d82dcd006c124e6569789c90390c43c1360c06 (diff)
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.
Diffstat (limited to 'src/gallium/auxiliary/tgsi/tgsi_build.c')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_build.c88
1 files changed, 64 insertions, 24 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c b/src/gallium/auxiliary/tgsi/tgsi_build.c
index 6ec2b0d8f21..6c3f77581f0 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
@@ -227,42 +227,66 @@ tgsi_build_declaration_semantic(
return ds;
}
-
static struct tgsi_declaration_resource
tgsi_default_declaration_resource(void)
{
- struct tgsi_declaration_resource declaration_resource;
+ struct tgsi_declaration_resource dr;
- declaration_resource.Resource = TGSI_TEXTURE_UNKNOWN;
- declaration_resource.ReturnTypeX = PIPE_TYPE_UNORM;
- declaration_resource.ReturnTypeY = PIPE_TYPE_UNORM;
- declaration_resource.ReturnTypeZ = PIPE_TYPE_UNORM;
- declaration_resource.ReturnTypeW = PIPE_TYPE_UNORM;
+ dr.Resource = TGSI_BUFFER;
- return declaration_resource;
+ return dr;
}
static struct tgsi_declaration_resource
tgsi_build_declaration_resource(unsigned texture,
- unsigned return_type_x,
- unsigned return_type_y,
- unsigned return_type_z,
- unsigned return_type_w,
struct tgsi_declaration *declaration,
struct tgsi_header *header)
{
- struct tgsi_declaration_resource declaration_resource;
+ struct tgsi_declaration_resource dr;
+
+ dr = tgsi_default_declaration_resource();
+ dr.Resource = texture;
+
+ declaration_grow(declaration, header);
+
+ return dr;
+}
+
+static struct tgsi_declaration_sampler_view
+tgsi_default_declaration_sampler_view(void)
+{
+ struct tgsi_declaration_sampler_view dsv;
+
+ dsv.Resource = TGSI_BUFFER;
+ dsv.ReturnTypeX = PIPE_TYPE_UNORM;
+ dsv.ReturnTypeY = PIPE_TYPE_UNORM;
+ dsv.ReturnTypeZ = PIPE_TYPE_UNORM;
+ dsv.ReturnTypeW = PIPE_TYPE_UNORM;
+
+ return dsv;
+}
+
+static struct tgsi_declaration_sampler_view
+tgsi_build_declaration_sampler_view(unsigned texture,
+ unsigned return_type_x,
+ unsigned return_type_y,
+ unsigned return_type_z,
+ unsigned return_type_w,
+ struct tgsi_declaration *declaration,
+ struct tgsi_header *header)
+{
+ struct tgsi_declaration_sampler_view dsv;
- declaration_resource = tgsi_default_declaration_resource();
- declaration_resource.Resource = texture;
- declaration_resource.ReturnTypeX = return_type_x;
- declaration_resource.ReturnTypeY = return_type_y;
- declaration_resource.ReturnTypeZ = return_type_z;
- declaration_resource.ReturnTypeW = return_type_w;
+ dsv = tgsi_default_declaration_sampler_view();
+ dsv.Resource = texture;
+ dsv.ReturnTypeX = return_type_x;
+ dsv.ReturnTypeY = return_type_y;
+ dsv.ReturnTypeZ = return_type_z;
+ dsv.ReturnTypeW = return_type_w;
declaration_grow(declaration, header);
- return declaration_resource;
+ return dsv;
}
@@ -276,6 +300,7 @@ tgsi_default_full_declaration( void )
full_declaration.Semantic = tgsi_default_declaration_semantic();
full_declaration.ImmediateData.u = NULL;
full_declaration.Resource = tgsi_default_declaration_resource();
+ full_declaration.SamplerView = tgsi_default_declaration_sampler_view();
return full_declaration;
}
@@ -375,14 +400,29 @@ tgsi_build_full_declaration(
size++;
*dr = tgsi_build_declaration_resource(full_decl->Resource.Resource,
- full_decl->Resource.ReturnTypeX,
- full_decl->Resource.ReturnTypeY,
- full_decl->Resource.ReturnTypeZ,
- full_decl->Resource.ReturnTypeW,
declaration,
header);
}
+ if (full_decl->Declaration.File == TGSI_FILE_SAMPLER_VIEW) {
+ struct tgsi_declaration_sampler_view *dsv;
+
+ if (maxsize <= size) {
+ return 0;
+ }
+ dsv = (struct tgsi_declaration_sampler_view *)&tokens[size];
+ size++;
+
+ *dsv = tgsi_build_declaration_sampler_view(
+ full_decl->SamplerView.Resource,
+ full_decl->SamplerView.ReturnTypeX,
+ full_decl->SamplerView.ReturnTypeY,
+ full_decl->SamplerView.ReturnTypeZ,
+ full_decl->SamplerView.ReturnTypeW,
+ declaration,
+ header);
+ }
+
return size;
}