mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-13 21:50:06 +00:00
5ee05891cf
Some languages allow a restricted set of user structure types returned from texture sampling operations. Restrictions include the total vector size of all components may not exceed 4, and the basic types of all members must be identical. This adds underpinnings for that ability. Because storing a whole TType or even a simple TTypeList in the TSampler would be expensive, the structure definition is held in a table outside the TType. The TSampler contains a small bitfield index, currently 4 bits to support up to 15 separate texture template structure types, but that can be adjusted up or down. Vector returns are handled as before. There are abstraction methods accepting and returning a TType (such as may have been parsed from a grammar). The new methods will accept a texture template type and set the sampler to the structure if possible, checking a range of error conditions such as whether the total structure vector components exceed 4, or whether their basic types differe, or whether the struct contains non-vector-or-scalar members. Another query returns the appropriate TType for the sampler. High level summary of design: In the TSampler, this holds an index into the texture structure return type table: unsigned int structReturnIndex : structReturnIndexBits; These are the methods to set or get the return type from the TSampler. They work for vector or structure returns, and potentially could be expanded to handle other things (small arrays?) if ever needed. bool setTextureReturnType(TSampler& sampler, const TType& retType, const TSourceLoc& loc); void getTextureReturnType(const TSampler& sampler, const TType& retType, const TSourceLoc& loc) const; The ``convertReturn`` lambda in ``HlslParseContext::decomposeSampleMethods`` is greatly expanded to know how to copy a vec4 sample return to whatever the structure type should be. This is a little awkward since it involves introducing a comma expression to return the proper aggregate value after a set of memberwise copies.
42 lines
1.1 KiB
GLSL
42 lines
1.1 KiB
GLSL
|
|
Texture2DMS <float> g_tTex2dmsf1;
|
|
Texture2DMS <float2> g_tTex2dmsf2;
|
|
Texture2DMS <float3> g_tTex2dmsf3;
|
|
Texture2DMS <float4> g_tTex2dmsf4;
|
|
|
|
Texture2D <float> g_tTex2df1;
|
|
Texture2D <float2> g_tTex2df2;
|
|
Texture2D <float3> g_tTex2df3;
|
|
Texture2D <float4> g_tTex2df4;
|
|
|
|
SamplerState g_sSamp;
|
|
|
|
float4 main() : SV_Target0
|
|
{
|
|
uint MipLevel;
|
|
uint WidthU;
|
|
uint HeightU;
|
|
uint ElementsU;
|
|
uint DepthU;
|
|
uint NumberOfLevelsU;
|
|
uint NumberOfSamplesU;
|
|
|
|
g_tTex2dmsf1 . GetDimensions(WidthU, HeightU, NumberOfSamplesU);
|
|
g_tTex2dmsf2 . GetDimensions(WidthU, HeightU, NumberOfSamplesU);
|
|
g_tTex2dmsf3 . GetDimensions(WidthU, HeightU, NumberOfSamplesU);
|
|
g_tTex2dmsf4 . GetDimensions(WidthU, HeightU, NumberOfSamplesU);
|
|
|
|
g_tTex2dmsf1 . Load(int2(1,2), 3);
|
|
g_tTex2dmsf2 . Load(int2(1,2), 3);
|
|
g_tTex2dmsf3 . Load(int2(1,2), 3);
|
|
g_tTex2dmsf4 . Load(int2(1,2), 3);
|
|
|
|
g_tTex2df1 . Sample(g_sSamp, float2(.1, .2));
|
|
g_tTex2df2 . Sample(g_sSamp, float2(.1, .2));
|
|
g_tTex2df3 . Sample(g_sSamp, float2(.1, .2));
|
|
g_tTex2df4 . Sample(g_sSamp, float2(.1, .2));
|
|
|
|
return 0;
|
|
}
|
|
|