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;
}
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;
}
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;
}
if (decl->Declaration.File == TGSI_FILE_RESOURCE) {
TXT(", ");
ENM(decl->Resource.Resource, tgsi_texture_names);
+ }
+
+ if (decl->Declaration.File == TGSI_FILE_SAMPLER_VIEW) {
TXT(", ");
- if ((decl->Resource.ReturnTypeX == decl->Resource.ReturnTypeY) &&
- (decl->Resource.ReturnTypeX == decl->Resource.ReturnTypeZ) &&
- (decl->Resource.ReturnTypeX == decl->Resource.ReturnTypeW)) {
- ENM(decl->Resource.ReturnTypeX, tgsi_type_names);
+ ENM(decl->SamplerView.Resource, tgsi_texture_names);
+ TXT(", ");
+ if ((decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeY) &&
+ (decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeZ) &&
+ (decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeW)) {
+ ENM(decl->SamplerView.ReturnTypeX, tgsi_type_names);
} else {
- ENM(decl->Resource.ReturnTypeX, tgsi_type_names);
+ ENM(decl->SamplerView.ReturnTypeX, tgsi_type_names);
TXT(", ");
- ENM(decl->Resource.ReturnTypeY, tgsi_type_names);
+ ENM(decl->SamplerView.ReturnTypeY, tgsi_type_names);
TXT(", ");
- ENM(decl->Resource.ReturnTypeZ, tgsi_type_names);
+ ENM(decl->SamplerView.ReturnTypeZ, tgsi_type_names);
TXT(", ");
- ENM(decl->Resource.ReturnTypeW, tgsi_type_names);
+ ENM(decl->SamplerView.ReturnTypeW, tgsi_type_names);
}
-
}
if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT &&
control = tgsi_sampler_lod_bias;
}
- switch (mach->Resources[resource_unit].Resource) {
+ switch (mach->SamplerViews[resource_unit].Resource) {
case TGSI_TEXTURE_1D:
case TGSI_TEXTURE_SHADOW1D:
FETCH(&r[0], 0, TGSI_CHAN_X);
* XXX: This is fake SAMPLE_D -- the derivatives are not taken into account, yet.
*/
- switch (mach->Resources[resource_unit].Resource) {
+ switch (mach->SamplerViews[resource_unit].Resource) {
case TGSI_TEXTURE_1D:
case TGSI_TEXTURE_SHADOW1D:
exec_declaration(struct tgsi_exec_machine *mach,
const struct tgsi_full_declaration *decl)
{
- if (decl->Declaration.File == TGSI_FILE_RESOURCE) {
- mach->Resources[decl->Range.First] = decl->Resource;
+ if (decl->Declaration.File == TGSI_FILE_SAMPLER_VIEW) {
+ mach->SamplerViews[decl->Range.First] = decl->SamplerView;
return;
}
exec_endswitch(mach);
break;
- case TGSI_OPCODE_LOAD:
+ case TGSI_OPCODE_SAMPLE_I:
assert(0);
break;
- case TGSI_OPCODE_LOAD_MS:
+ case TGSI_OPCODE_SAMPLE_I_MS:
assert(0);
break;
assert(0);
break;
- case TGSI_OPCODE_RESINFO:
+ case TGSI_OPCODE_SVIEWINFO:
assert(0);
break;
struct tgsi_full_declaration *Declarations;
uint NumDeclarations;
- struct tgsi_declaration_resource Resources[PIPE_MAX_SHADER_RESOURCES];
+ struct tgsi_declaration_sampler_view
+ SamplerViews[PIPE_MAX_SHADER_SAMPLER_VIEWS];
boolean UsedGeometryShader;
};
{ 0, 0, 0, 0, 0, 0, NONE, "DEFAULT", TGSI_OPCODE_DEFAULT },
{ 0, 0, 0, 0, 0, 0, NONE, "ENDSWITCH", TGSI_OPCODE_ENDSWITCH },
- { 1, 2, 0, 0, 0, 0, OTHR, "LOAD", TGSI_OPCODE_LOAD },
- { 1, 2, 0, 0, 0, 0, OTHR, "LOAD_MS", TGSI_OPCODE_LOAD_MS },
{ 1, 3, 0, 0, 0, 0, OTHR, "SAMPLE", TGSI_OPCODE_SAMPLE },
+ { 1, 2, 0, 0, 0, 0, OTHR, "SAMPLE_I", TGSI_OPCODE_SAMPLE_I },
+ { 1, 2, 0, 0, 0, 0, OTHR, "SAMPLE_I_MS", TGSI_OPCODE_SAMPLE_I_MS },
{ 1, 4, 0, 0, 0, 0, OTHR, "SAMPLE_B", TGSI_OPCODE_SAMPLE_B },
{ 1, 4, 0, 0, 0, 0, OTHR, "SAMPLE_C", TGSI_OPCODE_SAMPLE_C },
{ 1, 4, 0, 0, 0, 0, OTHR, "SAMPLE_C_LZ", TGSI_OPCODE_SAMPLE_C_LZ },
{ 1, 5, 0, 0, 0, 0, OTHR, "SAMPLE_D", TGSI_OPCODE_SAMPLE_D },
{ 1, 3, 0, 0, 0, 0, OTHR, "SAMPLE_L", TGSI_OPCODE_SAMPLE_L },
{ 1, 3, 0, 0, 0, 0, OTHR, "GATHER4", TGSI_OPCODE_GATHER4 },
- { 1, 2, 0, 0, 0, 0, OTHR, "RESINFO", TGSI_OPCODE_RESINFO },
+ { 1, 2, 0, 0, 0, 0, OTHR, "SVIEWINFO", TGSI_OPCODE_SVIEWINFO },
{ 1, 2, 0, 0, 0, 0, OTHR, "SAMPLE_POS", TGSI_OPCODE_SAMPLE_POS },
{ 1, 2, 0, 0, 0, 0, OTHR, "SAMPLE_INFO", TGSI_OPCODE_SAMPLE_INFO },
{ 1, 1, 0, 0, 0, 0, COMP, "UARL", TGSI_OPCODE_UARL },
{ 1, 3, 0, 0, 0, 0, COMP, "UCMP", TGSI_OPCODE_UCMP },
{ 1, 1, 0, 0, 0, 0, COMP, "IABS", TGSI_OPCODE_IABS },
{ 1, 1, 0, 0, 0, 0, COMP, "ISSG", TGSI_OPCODE_ISSG },
+ { 1, 2, 0, 0, 0, 0, OTHR, "LOAD", TGSI_OPCODE_LOAD },
};
const struct tgsi_opcode_info *
OP00(DEFAULT)
OP00(ENDSWITCH)
-OP12(LOAD)
-OP12(LOAD_MS)
OP13(SAMPLE)
+OP12(SAMPLE_I)
+OP12(SAMPLE_I_MS)
OP14(SAMPLE_B)
OP14(SAMPLE_C)
OP14(SAMPLE_C_LZ)
OP15(SAMPLE_D)
OP13(SAMPLE_L)
OP13(GATHER4)
-OP12(RESINFO)
+OP12(SVIEWINFO)
OP13(SAMPLE_POS)
OP12(SAMPLE_INFO)
next_token(ctx, &decl->Resource);
}
+ if (decl->Declaration.File == TGSI_FILE_SAMPLER_VIEW) {
+ next_token(ctx, &decl->SamplerView);
+ }
+
break;
}
struct tgsi_declaration_semantic Semantic;
struct tgsi_immediate_array_data ImmediateData;
struct tgsi_declaration_resource Resource;
+ struct tgsi_declaration_sampler_view SamplerView;
};
struct tgsi_full_immediate
"SV",
"IMMX",
"TEMPX",
- "RES"
+ "RES",
+ "SVIEW"
};
const char *tgsi_semantic_names[TGSI_SEMANTIC_COUNT] =
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 `,'" );
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);
}
}
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 {
struct tgsi_declaration_range decl_range;
struct tgsi_declaration_dimension decl_dim;
struct tgsi_declaration_semantic decl_semantic;
- struct tgsi_declaration_resource decl_resource;
+ struct tgsi_declaration_sampler_view decl_sampler_view;
struct tgsi_immediate imm;
union tgsi_immediate_data imm_data;
struct tgsi_instruction insn;
unsigned return_type_y;
unsigned return_type_z;
unsigned return_type_w;
- } resource[PIPE_MAX_SHADER_RESOURCES];
- unsigned nr_resources;
+ } sampler_view[PIPE_MAX_SHADER_SAMPLER_VIEWS];
+ unsigned nr_sampler_views;
unsigned temps_active[UREG_MAX_TEMP / 32];
unsigned nr_temps;
}
/*
- * Allocate a new shader resource.
+ * Allocate a new shader sampler view.
*/
struct ureg_src
-ureg_DECL_resource(struct ureg_program *ureg,
- unsigned index,
- unsigned target,
- unsigned return_type_x,
- unsigned return_type_y,
- unsigned return_type_z,
- unsigned return_type_w)
+ureg_DECL_sampler_view(struct ureg_program *ureg,
+ unsigned index,
+ unsigned target,
+ unsigned return_type_x,
+ unsigned return_type_y,
+ unsigned return_type_z,
+ unsigned return_type_w)
{
- struct ureg_src reg = ureg_src_register(TGSI_FILE_RESOURCE, index);
+ struct ureg_src reg = ureg_src_register(TGSI_FILE_SAMPLER_VIEW, index);
uint i;
- for (i = 0; i < ureg->nr_resources; i++) {
- if (ureg->resource[i].index == index) {
+ for (i = 0; i < ureg->nr_sampler_views; i++) {
+ if (ureg->sampler_view[i].index == index) {
return reg;
}
}
- if (i < PIPE_MAX_SHADER_RESOURCES) {
- ureg->resource[i].index = index;
- ureg->resource[i].target = target;
- ureg->resource[i].return_type_x = return_type_x;
- ureg->resource[i].return_type_y = return_type_y;
- ureg->resource[i].return_type_z = return_type_z;
- ureg->resource[i].return_type_w = return_type_w;
- ureg->nr_resources++;
+ if (i < PIPE_MAX_SHADER_SAMPLER_VIEWS) {
+ ureg->sampler_view[i].index = index;
+ ureg->sampler_view[i].target = target;
+ ureg->sampler_view[i].return_type_x = return_type_x;
+ ureg->sampler_view[i].return_type_y = return_type_y;
+ ureg->sampler_view[i].return_type_z = return_type_z;
+ ureg->sampler_view[i].return_type_w = return_type_w;
+ ureg->nr_sampler_views++;
return reg;
}
assert(dst.File != TGSI_FILE_CONSTANT);
assert(dst.File != TGSI_FILE_INPUT);
assert(dst.File != TGSI_FILE_SAMPLER);
- assert(dst.File != TGSI_FILE_RESOURCE);
+ assert(dst.File != TGSI_FILE_SAMPLER_VIEW);
assert(dst.File != TGSI_FILE_IMMEDIATE);
assert(dst.File < TGSI_FILE_COUNT);
}
static void
-emit_decl_resource(struct ureg_program *ureg,
- unsigned index,
- unsigned target,
- unsigned return_type_x,
- unsigned return_type_y,
- unsigned return_type_z,
- unsigned return_type_w )
+emit_decl_sampler_view(struct ureg_program *ureg,
+ unsigned index,
+ unsigned target,
+ unsigned return_type_x,
+ unsigned return_type_y,
+ unsigned return_type_z,
+ unsigned return_type_w )
{
union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 3);
out[0].value = 0;
out[0].decl.Type = TGSI_TOKEN_TYPE_DECLARATION;
out[0].decl.NrTokens = 3;
- out[0].decl.File = TGSI_FILE_RESOURCE;
+ out[0].decl.File = TGSI_FILE_SAMPLER_VIEW;
out[0].decl.UsageMask = 0xf;
out[0].decl.Interpolate = TGSI_INTERPOLATE_CONSTANT;
out[1].decl_range.Last = index;
out[2].value = 0;
- out[2].decl_resource.Resource = target;
- out[2].decl_resource.ReturnTypeX = return_type_x;
- out[2].decl_resource.ReturnTypeY = return_type_y;
- out[2].decl_resource.ReturnTypeZ = return_type_z;
- out[2].decl_resource.ReturnTypeW = return_type_w;
+ out[2].decl_sampler_view.Resource = target;
+ out[2].decl_sampler_view.ReturnTypeX = return_type_x;
+ out[2].decl_sampler_view.ReturnTypeY = return_type_y;
+ out[2].decl_sampler_view.ReturnTypeZ = return_type_z;
+ out[2].decl_sampler_view.ReturnTypeW = return_type_w;
}
static void
ureg->sampler[i].Index, 1 );
}
- for (i = 0; i < ureg->nr_resources; i++) {
- emit_decl_resource(ureg,
- ureg->resource[i].index,
- ureg->resource[i].target,
- ureg->resource[i].return_type_x,
- ureg->resource[i].return_type_y,
- ureg->resource[i].return_type_z,
- ureg->resource[i].return_type_w);
+ for (i = 0; i < ureg->nr_sampler_views; i++) {
+ emit_decl_sampler_view(ureg,
+ ureg->sampler_view[i].index,
+ ureg->sampler_view[i].target,
+ ureg->sampler_view[i].return_type_x,
+ ureg->sampler_view[i].return_type_y,
+ ureg->sampler_view[i].return_type_z,
+ ureg->sampler_view[i].return_type_w);
}
if (ureg->const_decls.nr_constant_ranges) {
unsigned index );
struct ureg_src
-ureg_DECL_resource(struct ureg_program *,
- unsigned index,
- unsigned target,
- unsigned return_type_x,
- unsigned return_type_y,
- unsigned return_type_z,
- unsigned return_type_w );
+ureg_DECL_sampler_view(struct ureg_program *,
+ unsigned index,
+ unsigned target,
+ unsigned return_type_x,
+ unsigned return_type_y,
+ unsigned return_type_z,
+ unsigned return_type_w );
static INLINE struct ureg_src
dst.zw = \sqrt{src.zw}
-.. _resourceopcodes:
+.. _samplingopcodes:
-Resource Access Opcodes
-^^^^^^^^^^^^^^^^^^^^^^^^
+Resource Sampling Opcodes
+^^^^^^^^^^^^^^^^^^^^^^^^^
Those opcodes follow very closely semantics of the respective Direct3D
instructions. If in doubt double check Direct3D documentation.
-.. opcode:: LOAD - Simplified alternative to the "SAMPLE" instruction.
- Using the provided integer address, LOAD fetches data
- from the specified buffer/texture without any filtering.
+.. opcode:: SAMPLE - Using provided address, sample data from the
+ specified texture using the filtering mode identified
+ by the gven sampler. The source data may come from
+ any resource type other than buffers.
+ SAMPLE dst, address, sampler_view, sampler
+ e.g.
+ SAMPLE TEMP[0], TEMP[1], SVIEW[0], SAMP[0]
+
+.. opcode:: SAMPLE_I - Simplified alternative to the SAMPLE instruction.
+ Using the provided integer address, SAMPLE_I fetches data
+ from the specified sampler view without any filtering.
The source data may come from any resource type other
than CUBE.
- LOAD dst, address, resource
+ SAMPLE_I dst, address, sampler_view
e.g.
- LOAD TEMP[0], TEMP[1], RES[0]
+ SAMPLE_I TEMP[0], TEMP[1], SVIEW[0]
The 'address' is specified as unsigned integers. If the
'address' is out of range [0...(# texels - 1)] the
result of the fetch is always 0 in all components.
As such the instruction doesn't honor address wrap
modes, in cases where that behavior is desirable
- 'sample' instruction should be used.
+ 'SAMPLE' instruction should be used.
address.w always provides an unsigned integer mipmap
level. If the value is out of the range then the
instruction always returns 0 in all components.
For 2D texture arrays address.z provides the array
index, otherwise it exhibits the same behavior as in
the case for 1D texture arrays.
- The exeact semantics of the source address are presented
+ The exact semantics of the source address are presented
in the table below:
resource type X Y Z W
------------- ------------------------
Where 'mpl' is a mipmap level and 'idx' is the
array index.
-
-.. opcode:: LOAD_MS - Just like LOAD but allows fetch data from
+.. opcode:: SAMPLE_I_MS - Just like SAMPLE_I but allows fetch data from
multi-sampled surfaces.
-.. opcode:: SAMPLE - Using provided address, sample data from the
- specified texture using the filtering mode identified
- by the gven sampler. The source data may come from
- any resource type other than buffers.
- SAMPLE dst, address, resource, sampler
- e.g.
- SAMPLE TEMP[0], TEMP[1], RES[0], SAMP[0]
-
.. opcode:: SAMPLE_B - Just like the SAMPLE instruction with the
exception that an additiona bias is applied to the
level of detail computed as part of the instruction
execution.
- SAMPLE_B dst, address, resource, sampler, lod_bias
+ SAMPLE_B dst, address, sampler_view, sampler, lod_bias
e.g.
- SAMPLE_B TEMP[0], TEMP[1], RES[0], SAMP[0], TEMP[2].x
+ SAMPLE_B TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2].x
.. opcode:: SAMPLE_C - Similar to the SAMPLE instruction but it
performs a comparison filter. The operands to SAMPLE_C
reference value against the red component value for the
surce resource at each texel that the currently configured
texture filter covers based on the provided coordinates.
- SAMPLE_C dst, address, resource.r, sampler, ref_value
+ SAMPLE_C dst, address, sampler_view.r, sampler, ref_value
e.g.
- SAMPLE_C TEMP[0], TEMP[1], RES[0].r, SAMP[0], TEMP[2].x
+ SAMPLE_C TEMP[0], TEMP[1], SVIEW[0].r, SAMP[0], TEMP[2].x
.. opcode:: SAMPLE_C_LZ - Same as SAMPLE_C, but LOD is 0 and derivatives
are ignored. The LZ stands for level-zero.
- SAMPLE_C_LZ dst, address, resource.r, sampler, ref_value
+ SAMPLE_C_LZ dst, address, sampler_view.r, sampler, ref_value
e.g.
- SAMPLE_C_LZ TEMP[0], TEMP[1], RES[0].r, SAMP[0], TEMP[2].x
+ SAMPLE_C_LZ TEMP[0], TEMP[1], SVIEW[0].r, SAMP[0], TEMP[2].x
.. opcode:: SAMPLE_D - SAMPLE_D is identical to the SAMPLE opcode except
that the derivatives for the source address in the x
direction and the y direction are provided by extra
parameters.
- SAMPLE_D dst, address, resource, sampler, der_x, der_y
+ SAMPLE_D dst, address, sampler_view, sampler, der_x, der_y
e.g.
- SAMPLE_D TEMP[0], TEMP[1], RES[0], SAMP[0], TEMP[2], TEMP[3]
+ SAMPLE_D TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2], TEMP[3]
.. opcode:: SAMPLE_L - SAMPLE_L is identical to the SAMPLE opcode except
that the LOD is provided directly as a scalar value,
representing no anisotropy. Source addresses A channel
is used as the LOD.
- SAMPLE_L dst, address, resource, sampler
+ SAMPLE_L dst, address, sampler_view, sampler
e.g.
- SAMPLE_L TEMP[0], TEMP[1], RES[0], SAMP[0]
-
+ SAMPLE_L TEMP[0], TEMP[1], SVIEW[0], SAMP[0]
.. opcode:: GATHER4 - Gathers the four texels to be used in a bi-linear
filtering operation and packs them into a single register.
the magnitude of the deltas are half a texel.
-.. opcode:: RESINFO - query the dimensions of a given input buffer.
+.. opcode:: SVIEWINFO - query the dimensions of a given sampler view.
dst receives width, height, depth or array size and
number of mipmap levels. The dst can have a writemask
which will specify what info is the caller interested
in.
- RESINFO dst, src_mip_level, resource
+ SVIEWINFO dst, src_mip_level, sampler_view
e.g.
- RESINFO TEMP[0], TEMP[1].x, RES[0]
+ SVIEWINFO TEMP[0], TEMP[1].x, SVIEW[0]
src_mip_level is an unsigned integer scalar. If it's
out of range then returns 0 for width, height and
depth/array size but the total number of mipmap is
- still returned correctly for the given resource.
+ still returned correctly for the given sampler view.
The returned width, height and depth values are for
the mipmap level selected by the src_mip_level and
are in the number of texels.
not a render target, the result is 0.
+.. _resourceopcodes:
+
+Resource Access Opcodes
+^^^^^^^^^^^^^^^^^^^^^^^
+
+.. opcode:: LOAD - Fetch data from a shader resource
+
+ Syntax: ``LOAD dst, resource, address``
+
+ Example: ``LOAD TEMP[0], RES[0], TEMP[1]``
+
+ Using the provided integer address, LOAD fetches data
+ from the specified buffer or texture without any
+ filtering.
+
+ The 'address' is specified as a vector of unsigned
+ integers. If the 'address' is out of range the result
+ is unspecified.
+
+ Only the first mipmap level of a resource can be read
+ from using this instruction.
+
+ For 1D or 2D texture arrays, the array index is
+ provided as an unsigned integer in address.y or
+ address.z, respectively. address.yz are ignored for
+ buffers and 1D textures. address.z is ignored for 1D
+ texture arrays and 2D textures. address.w is always
+ ignored.
+
+
Explanation of symbols used
------------------------------
This allows the fragment shader to change the fragments stencilref value.
-Declaration Resource
+Declaration Sampler View
^^^^^^^^^^^^^^^^^^^^^^^^
+ Follows Declaration token if file is TGSI_FILE_SAMPLER_VIEW.
+
+ DCL SVIEW[#], resource, type(s)
+
+ Declares a shader input sampler view and assigns it to a SVIEW[#]
+ register.
+
+ resource can be one of BUFFER, 1D, 2D, 3D, 1DArray and 2DArray.
+
+ type must be 1 or 4 entries (if specifying on a per-component
+ level) out of UNORM, SNORM, SINT, UINT and FLOAT.
+
+
+Declaration Resource
+^^^^^^^^^^^^^^^^^^^^
+
Follows Declaration token if file is TGSI_FILE_RESOURCE.
- DCL RES[#], resource, type(s)
+ DCL RES[#], resource
Declares a shader input resource and assigns it to a RES[#]
register.
resource can be one of BUFFER, 1D, 2D, 3D, CUBE, 1DArray and
2DArray.
- type must be 1 or 4 entries (if specifying on a per-component
- level) out of UNORM, SNORM, SINT, UINT and FLOAT.
-
Properties
^^^^^^^^^^^^^^^^^^^^^^^^
NV50_IR_OPCODE_CASE(SAMPLE_D, TXD);
NV50_IR_OPCODE_CASE(SAMPLE_L, TXL);
NV50_IR_OPCODE_CASE(GATHER4, TXG);
- NV50_IR_OPCODE_CASE(RESINFO, TXQ);
+ NV50_IR_OPCODE_CASE(SVIEWINFO, TXQ);
NV50_IR_OPCODE_CASE(END, EXIT);
int clipVertexOutput;
- uint8_t *resourceTargets; // TGSI_TEXTURE_*
- unsigned resourceCount;
+ uint8_t *samplerViewTargets; // TGSI_TEXTURE_*
+ unsigned samplerViewCount;
private:
int inferSysValDirection(unsigned sn) const;
if (prog->dbgFlags & NV50_IR_DEBUG_BASIC)
tgsi_dump(tokens, 0);
- resourceTargets = NULL;
+ samplerViewTargets = NULL;
mainTempsInLMem = FALSE;
}
if (info->immd.type)
FREE(info->immd.type);
- if (resourceTargets)
- delete[] resourceTargets;
+ if (samplerViewTargets)
+ delete[] samplerViewTargets;
}
bool Source::scanSource()
clipVertexOutput = -1;
- resourceCount = scan.file_max[TGSI_FILE_RESOURCE] + 1;
- resourceTargets = new uint8_t[resourceCount];
+ samplerViewCount = scan.file_max[TGSI_FILE_SAMPLER_VIEW] + 1;
+ samplerViewTargets = new uint8_t[samplerViewCount];
info->immd.bufSize = 0;
tempArrayCount = 0;
info->sv[i].input = inferSysValDirection(sn);
}
break;
- case TGSI_FILE_RESOURCE:
+ case TGSI_FILE_SAMPLER_VIEW:
for (i = first; i <= last; ++i)
- resourceTargets[i] = decl->Resource.Resource;
+ samplerViewTargets[i] = decl->SamplerView.Resource;
break;
case TGSI_FILE_IMMEDIATE_ARRAY:
{
nv50_ir::TexInstruction::Target
Instruction::getTexture(const tgsi::Source *code, int s) const
{
- if (insn->Instruction.Texture) {
- return translateTexture(insn->Texture.Texture);
- } else {
+ switch (getSrc(s).getFile()) {
+ case TGSI_FILE_SAMPLER_VIEW: {
// XXX: indirect access
unsigned int r = getSrc(s).getIndex(0);
- assert(r < code->resourceCount);
- return translateTexture(code->resourceTargets[r]);
+ assert(r < code->samplerViewCount);
+ return translateTexture(code->samplerViewTargets[r]);
+ }
+ default:
+ return translateTexture(insn->Texture.Texture);
}
}
handleTXF(dst0, 1);
break;
case TGSI_OPCODE_TXQ:
- case TGSI_OPCODE_RESINFO:
+ case TGSI_OPCODE_SVIEWINFO:
handleTXQ(dst0, TXQ_DIMS);
break;
case TGSI_OPCODE_F2I:
{TGSI_OPCODE_CASE, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
{TGSI_OPCODE_DEFAULT, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
{TGSI_OPCODE_ENDSWITCH, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
- {TGSI_OPCODE_LOAD, 0, 0, tgsi_unsupported},
- {TGSI_OPCODE_LOAD_MS, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE, 0, 0, tgsi_unsupported},
+ {TGSI_OPCODE_SAMPLE_I, 0, 0, tgsi_unsupported},
+ {TGSI_OPCODE_SAMPLE_I_MS, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE_B, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE_C, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE_C_LZ, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE_D, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE_L, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_GATHER4, 0, 0, tgsi_unsupported},
- {TGSI_OPCODE_RESINFO, 0, 0, tgsi_unsupported},
+ {TGSI_OPCODE_SVIEWINFO, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE_POS, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE_INFO, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_UARL, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT, tgsi_r600_arl},
{TGSI_OPCODE_CASE, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
{TGSI_OPCODE_DEFAULT, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
{TGSI_OPCODE_ENDSWITCH, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
- {TGSI_OPCODE_LOAD, 0, 0, tgsi_unsupported},
- {TGSI_OPCODE_LOAD_MS, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE, 0, 0, tgsi_unsupported},
+ {TGSI_OPCODE_SAMPLE_I, 0, 0, tgsi_unsupported},
+ {TGSI_OPCODE_SAMPLE_I_MS, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE_B, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE_C, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE_C_LZ, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE_D, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE_L, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_GATHER4, 0, 0, tgsi_unsupported},
- {TGSI_OPCODE_RESINFO, 0, 0, tgsi_unsupported},
+ {TGSI_OPCODE_SVIEWINFO, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE_POS, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE_INFO, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_UARL, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT, tgsi_eg_arl},
{TGSI_OPCODE_CASE, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
{TGSI_OPCODE_DEFAULT, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
{TGSI_OPCODE_ENDSWITCH, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
- {TGSI_OPCODE_LOAD, 0, 0, tgsi_unsupported},
- {TGSI_OPCODE_LOAD_MS, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE, 0, 0, tgsi_unsupported},
+ {TGSI_OPCODE_SAMPLE_I, 0, 0, tgsi_unsupported},
+ {TGSI_OPCODE_SAMPLE_I_MS, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE_B, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE_C, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE_C_LZ, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE_D, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE_L, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_GATHER4, 0, 0, tgsi_unsupported},
- {TGSI_OPCODE_RESINFO, 0, 0, tgsi_unsupported},
+ {TGSI_OPCODE_SVIEWINFO, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE_POS, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_SAMPLE_INFO, 0, 0, tgsi_unsupported},
{TGSI_OPCODE_UARL, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT, tgsi_eg_arl},
TGSI_FILE_IMMEDIATE_ARRAY =10,
TGSI_FILE_TEMPORARY_ARRAY =11,
TGSI_FILE_RESOURCE =12,
+ TGSI_FILE_SAMPLER_VIEW =13,
TGSI_FILE_COUNT /**< how many TGSI_FILE_ types */
};
};
struct tgsi_declaration_resource {
+ unsigned Resource : 8; /**< one of TGSI_TEXTURE_ */
+ unsigned Padding : 24;
+};
+
+struct tgsi_declaration_sampler_view {
unsigned Resource : 8; /**< one of TGSI_TEXTURE_ */
unsigned ReturnTypeX : 6; /**< one of enum pipe_type */
unsigned ReturnTypeY : 6; /**< one of enum pipe_type */
#define TGSI_OPCODE_ENDSWITCH 144
/* resource related opcodes */
-#define TGSI_OPCODE_LOAD 145
-#define TGSI_OPCODE_LOAD_MS 146
-#define TGSI_OPCODE_SAMPLE 147
+#define TGSI_OPCODE_SAMPLE 145
+#define TGSI_OPCODE_SAMPLE_I 146
+#define TGSI_OPCODE_SAMPLE_I_MS 147
#define TGSI_OPCODE_SAMPLE_B 148
#define TGSI_OPCODE_SAMPLE_C 149
#define TGSI_OPCODE_SAMPLE_C_LZ 150
#define TGSI_OPCODE_SAMPLE_D 151
#define TGSI_OPCODE_SAMPLE_L 152
#define TGSI_OPCODE_GATHER4 153
-#define TGSI_OPCODE_RESINFO 154
+#define TGSI_OPCODE_SVIEWINFO 154
#define TGSI_OPCODE_SAMPLE_POS 155
#define TGSI_OPCODE_SAMPLE_INFO 156
#define TGSI_OPCODE_IABS 159
#define TGSI_OPCODE_ISSG 160
-#define TGSI_OPCODE_LAST 161
+#define TGSI_OPCODE_LOAD 161
+
+#define TGSI_OPCODE_LAST 162
#define TGSI_SAT_NONE 0 /* do not saturate */
#define TGSI_SAT_ZERO_ONE 1 /* clamp to [0,1] */
break;
case SM4_OPCODE_RESINFO:
// TODO: return type
- ureg_RESINFO(ureg, _dst(), _src(1), resources[_idx(SM4_FILE_RESOURCE, 2)]);
+ ureg_SVIEWINFO(ureg, _dst(), _src(1), resources[_idx(SM4_FILE_RESOURCE, 2)]);
break;
// TODO: sample index, texture offset
case SM4_OPCODE_LD: // dst, coord_int, res; mipmap level in last coord_int arg
}
if(resources.size() <= (unsigned)idx)
resources.resize(idx + 1);
- resources[idx] = ureg_DECL_resource(ureg, idx, targets[idx].first,
- res_return_type(dcl.rrt.x),
- res_return_type(dcl.rrt.y),
- res_return_type(dcl.rrt.z),
- res_return_type(dcl.rrt.w));
+ resources[idx] = ureg_DECL_sampler_view(
+ ureg, idx, targets[idx].first,
+ res_return_type(dcl.rrt.x),
+ res_return_type(dcl.rrt.y),
+ res_return_type(dcl.rrt.z),
+ res_return_type(dcl.rrt.w));
break;
case SM4_OPCODE_DCL_SAMPLER:
check(idx >= 0);