Add support for texture rectangles. See gl-330-texture-rect

This commit is contained in:
baldurk
2014-12-01 22:55:35 +00:00
parent b0e36c551e
commit c51fade47a
8 changed files with 73 additions and 31 deletions
+1
View File
@@ -53,6 +53,7 @@ enum ShaderResourceType
eResType_Texture1D,
eResType_Texture1DArray,
eResType_Texture2D,
eResType_TextureRect,
eResType_Texture2DArray,
eResType_Texture2DMS,
eResType_Texture2DMSArray,
+16 -14
View File
@@ -97,21 +97,23 @@ BINDING(0) uniform HistogramCBufferData
#define CUBEMAP_FACE_POS_Z 4
#define CUBEMAP_FACE_NEG_Z 5
#define RESTYPE_TEX1D 0x1
#define RESTYPE_TEX2D 0x2
#define RESTYPE_TEX3D 0x3
#define RESTYPE_TEXCUBE 0x4
#define RESTYPE_TEX1DARRAY 0x5
#define RESTYPE_TEX2DARRAY 0x6
#define RESTYPE_TEXCUBEARRAY 0x7
#define RESTYPE_TEX1D 0x1
#define RESTYPE_TEX2D 0x2
#define RESTYPE_TEX3D 0x3
#define RESTYPE_TEXCUBE 0x4
#define RESTYPE_TEX1DARRAY 0x5
#define RESTYPE_TEX2DARRAY 0x6
#define RESTYPE_TEXCUBEARRAY 0x7
#define RESTYPE_TEXRECT 0x8
#define RESTYPE_TEXTYPEMAX 0x8
#define TEXDISPLAY_TYPEMASK 0x7
#define TEXDISPLAY_UINT_TEX 0x8
#define TEXDISPLAY_SINT_TEX 0x10
#define TEXDISPLAY_DEPTH_TEX 0x20
#define TEXDISPLAY_NANS 0x40
#define TEXDISPLAY_CLIPPING 0x80
#define TEXDISPLAY_GAMMA_CURVE 0x100
#define TEXDISPLAY_TYPEMASK 0xF
#define TEXDISPLAY_UINT_TEX 0x10
#define TEXDISPLAY_SINT_TEX 0x20
#define TEXDISPLAY_DEPTH_TEX 0x40
#define TEXDISPLAY_NANS 0x80
#define TEXDISPLAY_CLIPPING 0x100
#define TEXDISPLAY_GAMMA_CURVE 0x200
#ifndef FLT_EPSILON
#define FLT_EPSILON 1.192092896e-07f
+40 -10
View File
@@ -29,18 +29,21 @@ layout (binding = 4) uniform samplerCube texCube;
layout (binding = 5) uniform sampler1DArray tex1DArray;
layout (binding = 6) uniform sampler2DArray tex2DArray;
layout (binding = 7) uniform samplerCubeArray texCubeArray;
layout (binding = 8) uniform sampler2DRect tex2DRect;
layout (binding = 9) uniform usampler1D texUInt1D;
layout (binding = 10) uniform usampler2D texUInt2D;
layout (binding = 11) uniform usampler3D texUInt3D;
layout (binding = 13) uniform usampler1DArray texUInt1DArray;
layout (binding = 14) uniform usampler2DArray texUInt2DArray;
layout (binding = 17) uniform usampler1D texUInt1D;
layout (binding = 18) uniform usampler2D texUInt2D;
layout (binding = 19) uniform usampler3D texUInt3D;
layout (binding = 20) uniform usampler1DArray texUInt1DArray;
layout (binding = 21) uniform usampler2DArray texUInt2DArray;
layout (binding = 22) uniform usampler2DRect texUInt2DRect;
layout (binding = 16) uniform isampler1D texSInt1D;
layout (binding = 17) uniform isampler2D texSInt2D;
layout (binding = 18) uniform isampler3D texSInt3D;
layout (binding = 20) uniform isampler1DArray texSInt1DArray;
layout (binding = 21) uniform isampler2DArray texSInt2DArray;
layout (binding = 33) uniform isampler1D texSInt1D;
layout (binding = 34) uniform isampler2D texSInt2D;
layout (binding = 35) uniform isampler3D texSInt3D;
layout (binding = 36) uniform isampler1DArray texSInt1DArray;
layout (binding = 37) uniform isampler2DArray texSInt2DArray;
layout (binding = 38) uniform isampler2DRect texSInt2DRect;
vec3 CalcCubeCoord(vec2 uv, int face)
{
@@ -86,6 +89,15 @@ uvec4 SampleTextureUInt4(vec2 pos, int type, bool flipY, int mipLevel, float sli
col = texelFetch(texUInt2D, ivec2(pos), mipLevel);
}
else if (type == RESTYPE_TEXRECT)
{
ivec2 size = textureSize(texUInt2DRect, mipLevel);
if (flipY)
pos.y = size.y - pos.y;
col = texelFetch(texUInt2DRect, ivec2(pos));
}
else if (type == RESTYPE_TEX2DARRAY)
{
ivec3 size = textureSize(texUInt2DArray, mipLevel);
@@ -132,6 +144,15 @@ ivec4 SampleTextureSInt4(vec2 pos, int type, bool flipY, int mipLevel, float sli
col = texelFetch(texSInt2D, ivec2(pos), mipLevel);
}
else if (type == RESTYPE_TEXRECT)
{
ivec2 size = textureSize(texSInt2DRect, mipLevel);
if (flipY)
pos.y = size.y - pos.y;
col = texelFetch(texSInt2DRect, ivec2(pos));
}
else if (type == RESTYPE_TEX2DARRAY)
{
ivec3 size = textureSize(texSInt2DArray, mipLevel);
@@ -188,6 +209,15 @@ vec4 SampleTextureFloat4(vec2 pos, int type, bool flipY, bool linearSample, int
else
col = texelFetch(tex2D, ivec2(pos), mipLevel);
}
else if (type == RESTYPE_TEXRECT)
{
ivec2 size = textureSize(tex2DRect);
if (flipY)
pos.y = size.y - pos.y;
col = texelFetch(tex2DRect, ivec2(pos));
}
else if (type == RESTYPE_TEX2DARRAY)
{
ivec3 size = textureSize(tex2DArray, mipLevel);
+6 -1
View File
@@ -234,7 +234,9 @@ void GLReplay::InitDebugData()
RDCEraseEl(DebugData.histogramProgram);
RDCEraseEl(DebugData.minmaxResultProgram);
for(int t=1; t <= TEXDISPLAY_TYPEMASK; t++)
RDCCOMPILE_ASSERT(ARRAY_COUNT(DebugData.minmaxTileProgram) >= (TEXDISPLAY_SINT_TEX|TEXDISPLAY_TYPEMASK)+1, "not enough programs");
for(int t=1; t <= RESTYPE_TEXTYPEMAX; t++)
{
// float, uint, sint
for(int i=0; i < 3; i++)
@@ -581,6 +583,9 @@ bool GLReplay::RenderTexture(TextureDisplay cfg)
case eGL_TEXTURE_2D:
resType = RESTYPE_TEX2D;
break;
case eGL_TEXTURE_RECTANGLE:
resType = RESTYPE_TEXRECT;
break;
case eGL_TEXTURE_3D:
resType = RESTYPE_TEX3D;
break;
+3
View File
@@ -1148,6 +1148,9 @@ void GLReplay::SavePipelineState()
case eResType_Texture2D:
target = eGL_TEXTURE_2D;
break;
case eResType_TextureRect:
target = eGL_TEXTURE_RECTANGLE;
break;
case eResType_Texture2DArray:
target = eGL_TEXTURE_2D_ARRAY;
break;
+2 -2
View File
@@ -180,8 +180,8 @@ class GLReplay : public IReplayDriver
GLuint minmaxResult; // Vec4f[2] final result buffer
GLuint histogramBuf; // uint32_t * num buckets buffer
GLuint minmaxResultProgram[3]; // float/uint/sint tile result -> final result program
GLuint minmaxTileProgram[32]; // RESTYPE indexed (see debuguniforms.h, 1d/2d/3d etc | uint/sint) src tex -> tile result buf program
GLuint histogramProgram[32]; // RESTYPE indexed (see debuguniforms.h, 1d/2d/3d etc | uint/sint) src tex -> histogram result buf program
GLuint minmaxTileProgram[64]; // RESTYPE indexed (see debuguniforms.h, 1d/2d/3d etc | uint/sint) src tex -> tile result buf program
GLuint histogramProgram[64]; // RESTYPE indexed (see debuguniforms.h, 1d/2d/3d etc | uint/sint) src tex -> histogram result buf program
GLuint replayQuadProg;
+4 -4
View File
@@ -264,13 +264,13 @@ void MakeShaderReflection(const GLHookSet &gl, GLenum shadType, GLuint sepProg,
}
else if(values[0] == GL_SAMPLER_2D_RECT)
{
res.resType = eResType_Texture2D;
res.resType = eResType_TextureRect;
res.variableType.descriptor.name = "sampler2DRect";
res.variableType.descriptor.type = eVar_Float;
}
else if(values[0] == GL_SAMPLER_2D_RECT_SHADOW)
{
res.resType = eResType_Texture2D;
res.resType = eResType_TextureRect;
res.variableType.descriptor.name = "sampler2DRectShadow";
res.variableType.descriptor.type = eVar_Float;
}
@@ -343,7 +343,7 @@ void MakeShaderReflection(const GLHookSet &gl, GLenum shadType, GLuint sepProg,
}
else if(values[0] == GL_INT_SAMPLER_2D_RECT)
{
res.resType = eResType_Texture2D;
res.resType = eResType_TextureRect;
res.variableType.descriptor.name = "sampler2DRect";
res.variableType.descriptor.type = eVar_Int;
}
@@ -410,7 +410,7 @@ void MakeShaderReflection(const GLHookSet &gl, GLenum shadType, GLuint sepProg,
}
else if(values[0] == GL_UNSIGNED_INT_SAMPLER_2D_RECT)
{
res.resType = eResType_Texture2D;
res.resType = eResType_TextureRect;
res.variableType.descriptor.name = "sampler2DRect";
res.variableType.descriptor.type = eVar_UInt;
}
+1
View File
@@ -55,6 +55,7 @@ namespace renderdoc
Texture1D,
Texture1DArray,
Texture2D,
TextureRect,
Texture2DArray,
Texture2DMS,
Texture2DMSArray,