Display texture swizzling and depth/stencil read mode on textures

This commit is contained in:
baldurk
2015-01-17 15:53:09 +00:00
parent ce7c8eb44f
commit 24fd91a7e0
6 changed files with 111 additions and 1 deletions
+3
View File
@@ -73,6 +73,9 @@ struct GLPipelineState
ResourceId Resource;
uint32_t FirstSlice;
ShaderResourceType ResType;
TextureSwizzle Swizzle[4];
int32_t DepthReadChannel;
};
rdctype::array<Texture> Textures;
+10
View File
@@ -46,6 +46,16 @@ enum FormatComponentType
eCompType_Double,
};
enum TextureSwizzle
{
eSwizzle_Red,
eSwizzle_Green,
eSwizzle_Blue,
eSwizzle_Alpha,
eSwizzle_Zero,
eSwizzle_One,
};
enum ShaderResourceType
{
eResType_None,
+47 -1
View File
@@ -1259,7 +1259,53 @@ void GLReplay::SavePipelineState()
pipe.Textures[unit].Resource = rm->GetOriginalID(rm->GetID(TextureRes(ctx, tex)));
pipe.Textures[unit].FirstSlice = (uint32_t)firstSlice;
pipe.Textures[unit].ResType = resType;
pipe.Textures[unit].DepthReadChannel = -1;
GLenum levelQueryType = target == eGL_TEXTURE_CUBE_MAP ? eGL_TEXTURE_CUBE_MAP_POSITIVE_X : target;
GLenum fmt = eGL_NONE;
gl.glGetTexLevelParameteriv(levelQueryType, 0, eGL_TEXTURE_INTERNAL_FORMAT, (GLint *)&fmt);
if(IsDepthStencilFormat(fmt))
{
GLint depthMode;
gl.glGetTexParameteriv(target, eGL_DEPTH_STENCIL_TEXTURE_MODE, &depthMode);
if(depthMode == eGL_DEPTH_COMPONENT)
pipe.Textures[unit].DepthReadChannel = 0;
else if(depthMode == eGL_STENCIL_INDEX)
pipe.Textures[unit].DepthReadChannel = 1;
}
GLint swizzles[4] = { eGL_RED, eGL_GREEN, eGL_BLUE, eGL_ALPHA };
if(target != eGL_TEXTURE_BUFFER)
gl.glGetTexParameteriv(target, eGL_TEXTURE_SWIZZLE_RGBA, swizzles);
for(int i=0; i < 4; i++)
{
switch(swizzles[i])
{
default:
case GL_ZERO:
pipe.Textures[unit].Swizzle[i] = eSwizzle_Zero;
break;
case GL_ONE:
pipe.Textures[unit].Swizzle[i] = eSwizzle_One;
break;
case eGL_RED:
pipe.Textures[unit].Swizzle[i] = eSwizzle_Red;
break;
case eGL_GREEN:
pipe.Textures[unit].Swizzle[i] = eSwizzle_Green;
break;
case eGL_BLUE:
pipe.Textures[unit].Swizzle[i] = eSwizzle_Blue;
break;
case eGL_ALPHA:
pipe.Textures[unit].Swizzle[i] = eSwizzle_Alpha;
break;
}
}
GLuint samp;
gl.glGetIntegerv(eGL_SAMPLER_BINDING, (GLint *)&samp);
+25
View File
@@ -48,6 +48,16 @@ namespace renderdoc
Double,
};
public enum TextureSwizzle
{
Red,
Green,
Blue,
Alpha,
Zero,
One,
};
public enum ShaderResourceType
{
None,
@@ -434,6 +444,21 @@ namespace renderdoc
return "Unknown Type";
}
public static string Str(this TextureSwizzle swiz)
{
switch (swiz)
{
case TextureSwizzle.Red: return "R";
case TextureSwizzle.Green: return "G";
case TextureSwizzle.Blue: return "B";
case TextureSwizzle.Alpha: return "A";
case TextureSwizzle.Zero: return "0";
case TextureSwizzle.One: return "1";
}
return "Unknown";
}
public static string Str(this ReplayCreateStatus status)
{
switch (status)
+3
View File
@@ -96,6 +96,9 @@ namespace renderdoc
public ResourceId Resource;
public UInt32 FirstSlice;
public ShaderResourceType ResType;
[CustomMarshalAs(CustomUnmanagedType.FixedArray, FixedLength = 4)]
public TextureSwizzle[] Swizzle;
public Int32 DepthReadChannel;
};
[CustomMarshalAs(CustomUnmanagedType.TemplatedArray)]
public Texture[] Textures;
@@ -265,6 +265,29 @@ namespace renderdocui.Windows.PipelineState
name = texs[t].name;
typename = texs[t].resType.ToString();
if (texs[t].format.special &&
(texs[t].format.specialFormat == SpecialFormat.D24S8 ||
texs[t].format.specialFormat == SpecialFormat.D32S8)
)
{
if (r.DepthReadChannel == 0)
format += " Depth-Read";
else if (r.DepthReadChannel == 1)
format += " Stencil-Read";
}
else if (
r.Swizzle[0] != TextureSwizzle.Red ||
r.Swizzle[1] != TextureSwizzle.Green ||
r.Swizzle[2] != TextureSwizzle.Blue ||
r.Swizzle[3] != TextureSwizzle.Alpha)
{
format += String.Format(" swizzle[{0}{1}{2}{3}]",
r.Swizzle[0].Str(),
r.Swizzle[1].Str(),
r.Swizzle[2].Str(),
r.Swizzle[3].Str());
}
tag = texs[t];
}
}