Pass through ShaderResourceType per-texture for better type naming

This commit is contained in:
baldurk
2015-01-17 15:03:34 +00:00
parent af545e00c7
commit 7e10c5c4ea
8 changed files with 70 additions and 28 deletions
+1
View File
@@ -95,6 +95,7 @@ struct FetchTexture
bool32 customName;
ResourceFormat format;
uint32_t dimension;
ShaderResourceType resType;
uint32_t width, height, depth;
ResourceId ID;
bool32 cubemap;
+1
View File
@@ -72,6 +72,7 @@ struct GLPipelineState
{
ResourceId Resource;
uint32_t FirstSlice;
ShaderResourceType ResType;
};
rdctype::array<Texture> Textures;
+10
View File
@@ -87,6 +87,8 @@ FetchTexture D3D11Replay::GetTexture(ResourceId id)
tex.mips = tex.numSubresources;
tex.arraysize = desc.ArraySize;
tex.resType = tex.arraysize > 1 ? eResType_Texture1DArray : eResType_Texture1D;
tex.msQual = 0; tex.msSamp = 1;
tex.numSubresources *= desc.ArraySize;
@@ -165,6 +167,12 @@ FetchTexture D3D11Replay::GetTexture(ResourceId id)
tex.msQual = desc.SampleDesc.Quality; tex.msSamp = desc.SampleDesc.Count;
tex.resType = tex.arraysize > 1 ? eResType_Texture2DArray : eResType_Texture2D;
if(tex.cubemap)
tex.resType = tex.arraysize > 1 ? eResType_TextureCubeArray : eResType_TextureCube;
if(tex.msSamp > 1)
tex.resType = tex.arraysize > 1 ? eResType_Texture2DMSArray : eResType_Texture2DMS;
tex.numSubresources *= desc.ArraySize;
tex.customName = true;
@@ -229,6 +237,8 @@ FetchTexture D3D11Replay::GetTexture(ResourceId id)
tex.numSubresources = desc.MipLevels;
tex.resType = eResType_Texture3D;
tex.creationFlags = 0;
if(desc.BindFlags & D3D11_BIND_SHADER_RESOURCE)
tex.creationFlags |= eTextureCreate_SRV;
+47
View File
@@ -360,6 +360,7 @@ void GLReplay::CacheTexture(ResourceId id)
tex.customName = false;
tex.format = ResourceFormat();
tex.dimension = 1;
tex.resType = eResType_None;
tex.width = tex.height = tex.depth = 1;
tex.cubemap = false;
tex.mips = 1;
@@ -377,6 +378,7 @@ void GLReplay::CacheTexture(ResourceId id)
if(res.resource.Namespace == eResRenderbuffer || res.curType == eGL_RENDERBUFFER)
{
tex.dimension = 2;
tex.resType = eResType_Texture2D;
tex.width = res.width;
tex.height = res.height;
tex.depth = 1;
@@ -458,7 +460,48 @@ void GLReplay::CacheTexture(ResourceId id)
tex.msSamp = 1;
tex.width = tex.height = tex.depth = tex.arraysize = 1;
tex.cubemap = false;
switch(target)
{
case eGL_TEXTURE_BUFFER:
tex.resType = eResType_Buffer;
break;
case eGL_TEXTURE_1D:
tex.resType = eResType_Texture1D;
break;
case eGL_TEXTURE_2D:
tex.resType = eResType_Texture2D;
break;
case eGL_TEXTURE_3D:
tex.resType = eResType_Texture3D;
break;
case eGL_TEXTURE_1D_ARRAY:
tex.resType = eResType_Texture1DArray;
break;
case eGL_TEXTURE_2D_ARRAY:
tex.resType = eResType_Texture2DArray;
break;
case eGL_TEXTURE_RECTANGLE:
tex.resType = eResType_TextureRect;
break;
case eGL_TEXTURE_2D_MULTISAMPLE:
tex.resType = eResType_Texture2DMS;
break;
case eGL_TEXTURE_2D_MULTISAMPLE_ARRAY:
tex.resType = eResType_Texture2DMSArray;
break;
case eGL_TEXTURE_CUBE_MAP:
tex.resType = eResType_TextureCube;
break;
case eGL_TEXTURE_CUBE_MAP_ARRAY:
tex.resType = eResType_TextureCubeArray;
break;
default:
tex.resType = eResType_None;
RDCERR("Unexpected texture enum %s", ToStr::Get(target).c_str());
}
switch(target)
{
case eGL_TEXTURE_1D:
@@ -1120,6 +1163,7 @@ void GLReplay::SavePipelineState()
{
GLenum binding = eGL_NONE;
GLenum target = eGL_NONE;
ShaderResourceType resType = eResType_None;
bool shadow = false;
@@ -1180,6 +1224,8 @@ void GLReplay::SavePipelineState()
if(target != eGL_NONE)
t = TextureBinding(target);
resType = refls[s]->Resources[r].resType;
if(binding == eGL_NONE)
{
binding = t;
@@ -1212,6 +1258,7 @@ 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;
GLuint samp;
gl.glGetIntegerv(eGL_SAMPLER_BINDING, (GLint *)&samp);