From 192ff9c0079bde0a5898a33a5ac5528ba39f2f39 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 3 Dec 2014 12:31:00 +0000 Subject: [PATCH] Texbuffer display for GL --- renderdoc/data/glsl/debuguniforms.h | 5 ++-- renderdoc/data/glsl/texdisplay.frag | 5 ++-- renderdoc/data/glsl/texsample.h | 23 ++++++++++++++++--- renderdoc/driver/gl/gl_debug.cpp | 11 ++++++++- .../driver/gl/wrappers/gl_texture_funcs.cpp | 10 +++++--- 5 files changed, 43 insertions(+), 11 deletions(-) diff --git a/renderdoc/data/glsl/debuguniforms.h b/renderdoc/data/glsl/debuguniforms.h index c3dca1cf0..74a0a9ec1 100644 --- a/renderdoc/data/glsl/debuguniforms.h +++ b/renderdoc/data/glsl/debuguniforms.h @@ -109,8 +109,9 @@ BINDING(0) uniform HistogramCBufferData #define RESTYPE_TEX2DARRAY 0x6 #define RESTYPE_TEXCUBEARRAY 0x7 #define RESTYPE_TEXRECT 0x8 -#define RESTYPE_TEX2DMS 0x9 -#define RESTYPE_TEXTYPEMAX 0x9 +#define RESTYPE_TEXBUFFER 0x9 +#define RESTYPE_TEX2DMS 0xA +#define RESTYPE_TEXTYPEMAX 0xA #define TEXDISPLAY_TYPEMASK 0xF #define TEXDISPLAY_UINT_TEX 0x10 diff --git a/renderdoc/data/glsl/texdisplay.frag b/renderdoc/data/glsl/texdisplay.frag index 3b584ee8f..d42a36ad0 100644 --- a/renderdoc/data/glsl/texdisplay.frag +++ b/renderdoc/data/glsl/texdisplay.frag @@ -41,9 +41,10 @@ void main(void) int texType = (OutputDisplayFormat & TEXDISPLAY_TYPEMASK); - if(texType == RESTYPE_TEX1D || texType == RESTYPE_TEX1DARRAY) + if(texType == RESTYPE_TEX1D || texType == RESTYPE_TEXBUFFER || texType == RESTYPE_TEX1DARRAY) { - if(scr.x < 0.0f || scr.x > TextureResolutionPS.x) + // by convention display 1D textures as 100 high + if(scr.x < 0.0f || scr.x > TextureResolutionPS.x || scr.y < 0.0f || scr.y > 100.0f) discard; } else diff --git a/renderdoc/data/glsl/texsample.h b/renderdoc/data/glsl/texsample.h index d43c5f1ad..eab32405e 100644 --- a/renderdoc/data/glsl/texsample.h +++ b/renderdoc/data/glsl/texsample.h @@ -22,6 +22,8 @@ * THE SOFTWARE. ******************************************************************************/ +// these bindings are defined based on the RESTYPE_ defines in debuguniforms.h +// optionally TEXDISPLAY_UINT_TEX or TEXDISPLAY_SINT_TEX, OR'd with RESTYPE_* layout (binding = 1) uniform sampler1D tex1D; layout (binding = 2) uniform sampler2D tex2D; layout (binding = 3) uniform sampler3D tex3D; @@ -30,7 +32,8 @@ 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 sampler2DMS tex2DMS; +layout (binding = 9) uniform samplerBuffer texBuffer; +layout (binding = 10) uniform sampler2DMS tex2DMS; layout (binding = 17) uniform usampler1D texUInt1D; layout (binding = 18) uniform usampler2D texUInt2D; @@ -38,7 +41,8 @@ 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 = 23) uniform usampler2DMS texUInt2DMS; +layout (binding = 23) uniform usamplerBuffer texUIntBuffer; +layout (binding = 24) uniform usampler2DMS texUInt2DMS; layout (binding = 33) uniform isampler1D texSInt1D; layout (binding = 34) uniform isampler2D texSInt2D; @@ -46,7 +50,8 @@ layout (binding = 35) uniform isampler3D texSInt3D; layout (binding = 36) uniform isampler1DArray texSInt1DArray; layout (binding = 37) uniform isampler2DArray texSInt2DArray; layout (binding = 38) uniform isampler2DRect texSInt2DRect; -layout (binding = 39) uniform isampler2DMS texSInt2DMS; +layout (binding = 39) uniform isamplerBuffer texSIntBuffer; +layout (binding = 40) uniform isampler2DMS texSInt2DMS; vec3 CalcCubeCoord(vec2 uv, int face) { @@ -101,6 +106,10 @@ uvec4 SampleTextureUInt4(vec2 pos, int type, bool flipY, int mipLevel, float sli col = texelFetch(texUInt2DRect, ivec2(pos)); } + else if (type == RESTYPE_TEXBUFFER) + { + col = texelFetch(texUIntBuffer, int(pos.x)); + } else if (type == RESTYPE_TEX2DMS) { ivec2 size = textureSize(texUInt2DMS); @@ -168,6 +177,10 @@ ivec4 SampleTextureSInt4(vec2 pos, int type, bool flipY, int mipLevel, float sli col = texelFetch(texSInt2DRect, ivec2(pos)); } + else if (type == RESTYPE_TEXBUFFER) + { + col = texelFetch(texSIntBuffer, int(pos.x)); + } else if (type == RESTYPE_TEX2DMS) { ivec2 size = textureSize(texSInt2DMS); @@ -245,6 +258,10 @@ vec4 SampleTextureFloat4(vec2 pos, int type, bool flipY, bool linearSample, int col = texelFetch(tex2DRect, ivec2(pos)); } + else if (type == RESTYPE_TEXBUFFER) + { + col = texelFetch(texBuffer, int(pos.x)); + } else if (type == RESTYPE_TEX2DMS) { ivec2 size = textureSize(tex2DMS); diff --git a/renderdoc/driver/gl/gl_debug.cpp b/renderdoc/driver/gl/gl_debug.cpp index eb1fa3d23..4924f72df 100644 --- a/renderdoc/driver/gl/gl_debug.cpp +++ b/renderdoc/driver/gl/gl_debug.cpp @@ -340,6 +340,9 @@ bool GLReplay::GetMinMax(ResourceId texid, uint32_t sliceFace, uint32_t mip, uin case eGL_TEXTURE_RECTANGLE: texSlot = RESTYPE_TEXRECT; break; + case eGL_TEXTURE_BUFFER: + texSlot = RESTYPE_TEXBUFFER; + break; case eGL_TEXTURE_3D: texSlot = RESTYPE_TEX3D; break; @@ -497,6 +500,9 @@ bool GLReplay::GetHistogram(ResourceId texid, uint32_t sliceFace, uint32_t mip, case eGL_TEXTURE_RECTANGLE: texSlot = RESTYPE_TEXRECT; break; + case eGL_TEXTURE_BUFFER: + texSlot = RESTYPE_TEXBUFFER; + break; case eGL_TEXTURE_3D: texSlot = RESTYPE_TEX3D; break; @@ -677,6 +683,9 @@ bool GLReplay::RenderTexture(TextureDisplay cfg) case eGL_TEXTURE_RECTANGLE: resType = RESTYPE_TEXRECT; break; + case eGL_TEXTURE_BUFFER: + resType = RESTYPE_TEXBUFFER; + break; case eGL_TEXTURE_3D: resType = RESTYPE_TEX3D; break; @@ -782,7 +791,7 @@ bool GLReplay::RenderTexture(TextureDisplay cfg) int maxlevel = -1; - if(cfg.mip == 0 && cfg.scale < 1.0f && dsTexMode == eGL_NONE) + if(cfg.mip == 0 && cfg.scale < 1.0f && dsTexMode == eGL_NONE && resType != eGL_TEXTURE_BUFFER) { gl.glGetTextureParameterivEXT(texname, target, eGL_TEXTURE_MAX_LEVEL, (GLint *)&maxlevel); diff --git a/renderdoc/driver/gl/wrappers/gl_texture_funcs.cpp b/renderdoc/driver/gl/wrappers/gl_texture_funcs.cpp index 31fdad0a0..df7214930 100644 --- a/renderdoc/driver/gl/wrappers/gl_texture_funcs.cpp +++ b/renderdoc/driver/gl/wrappers/gl_texture_funcs.cpp @@ -3216,7 +3216,7 @@ bool WrappedOpenGL::Serialise_glTextureBufferRangeEXT(GLuint texture, GLenum tar if(m_State == READING) { ResourceId liveId = GetResourceManager()->GetLiveID(texid); - m_Textures[liveId].width = 1; + m_Textures[liveId].width = uint32_t(Size)/GetByteSize(1, 1, 1, GetBaseFormat(fmt), GetDataType(fmt), 1); m_Textures[liveId].height = 1; m_Textures[liveId].depth = 1; m_Textures[liveId].curType = TextureTarget(Target); @@ -3275,8 +3275,12 @@ bool WrappedOpenGL::Serialise_glTextureBufferEXT(GLuint texture, GLenum target, if(m_State == READING) { + buffer = GetResourceManager()->GetLiveResource(bufid).name; + ResourceId liveId = GetResourceManager()->GetLiveID(texid); - m_Textures[liveId].width = 1; + uint32_t Size = 1; + m_Real.glGetNamedBufferParameterivEXT(buffer, eGL_BUFFER_SIZE, (GLint *)&Size); + m_Textures[liveId].width = Size/GetByteSize(1, 1, 1, GetBaseFormat(fmt), GetDataType(fmt), 1); m_Textures[liveId].height = 1; m_Textures[liveId].depth = 1; m_Textures[liveId].curType = TextureTarget(Target); @@ -3284,7 +3288,7 @@ bool WrappedOpenGL::Serialise_glTextureBufferEXT(GLuint texture, GLenum target, m_Real.glTextureBufferEXT(GetResourceManager()->GetLiveResource(texid).name, Target, fmt, - GetResourceManager()->GetLiveResource(bufid).name); + buffer); } return true;