diff --git a/XenosRecomp/shader_common.h b/XenosRecomp/shader_common.h index 91973a1..9e0af6f 100644 --- a/XenosRecomp/shader_common.h +++ b/XenosRecomp/shader_common.h @@ -78,22 +78,22 @@ uint g_SpecConstants(); struct Texture2DDescriptorHeap { - array, 1> g [[id(0)]]; + texture2d tex; }; struct Texture3DDescriptorHeap { - array, 1> g [[id(0)]]; + texture3d tex; }; struct TextureCubeDescriptorHeap { - array, 1> g [[id(0)]]; + texturecube tex; }; struct SamplerDescriptorHeap { - array g [[id(0)]]; + sampler samp; }; uint2 getTexture2DDimensions(texture2d texture) @@ -101,24 +101,24 @@ uint2 getTexture2DDimensions(texture2d texture) return uint2(texture.get_width(), texture.get_height()); } -float4 tfetch2D(constant Texture2DDescriptorHeap& textureHeap, - constant SamplerDescriptorHeap& samplerHeap, +float4 tfetch2D(constant Texture2DDescriptorHeap* textureHeap, + constant SamplerDescriptorHeap* samplerHeap, uint resourceDescriptorIndex, uint samplerDescriptorIndex, float2 texCoord, float2 offset) { - texture2d texture = textureHeap.g[resourceDescriptorIndex]; - sampler sampler = samplerHeap.g[samplerDescriptorIndex]; + texture2d texture = textureHeap[resourceDescriptorIndex].tex; + sampler sampler = samplerHeap[samplerDescriptorIndex].samp; return texture.sample(sampler, texCoord + offset / (float2)getTexture2DDimensions(texture)); } -float2 getWeights2D(constant Texture2DDescriptorHeap& textureHeap, - constant SamplerDescriptorHeap& samplerHeap, +float2 getWeights2D(constant Texture2DDescriptorHeap* textureHeap, + constant SamplerDescriptorHeap* samplerHeap, uint resourceDescriptorIndex, uint samplerDescriptorIndex, float2 texCoord, float2 offset) { - texture2d texture = textureHeap.g[resourceDescriptorIndex]; + texture2d texture = textureHeap[resourceDescriptorIndex].tex; return select(fract(texCoord * (float2)getTexture2DDimensions(texture) + offset - 0.5), 0.0, isnan(texCoord)); } @@ -236,14 +236,14 @@ struct CubeMapData #ifdef __air__ -float4 tfetch2DBicubic(constant Texture2DDescriptorHeap& textureHeap, - constant SamplerDescriptorHeap& samplerHeap, +float4 tfetch2DBicubic(constant Texture2DDescriptorHeap* textureHeap, + constant SamplerDescriptorHeap* samplerHeap, uint resourceDescriptorIndex, uint samplerDescriptorIndex, float2 texCoord, float2 offset) { - texture2d texture = textureHeap.g[resourceDescriptorIndex]; - sampler sampler = samplerHeap.g[samplerDescriptorIndex]; + texture2d texture = textureHeap[resourceDescriptorIndex].tex; + sampler sampler = samplerHeap[samplerDescriptorIndex].samp; uint2 dimensions = getTexture2DDimensions(texture); float x = texCoord.x * dimensions.x + offset.x; @@ -272,25 +272,25 @@ float4 tfetch2DBicubic(constant Texture2DDescriptorHeap& textureHeap, return r; } -float4 tfetch3D(constant Texture3DDescriptorHeap& textureHeap, - constant SamplerDescriptorHeap& samplerHeap, +float4 tfetch3D(constant Texture3DDescriptorHeap* textureHeap, + constant SamplerDescriptorHeap* samplerHeap, uint resourceDescriptorIndex, uint samplerDescriptorIndex, float3 texCoord) { - texture3d texture = textureHeap.g[resourceDescriptorIndex]; - sampler sampler = samplerHeap.g[samplerDescriptorIndex]; + texture3d texture = textureHeap[resourceDescriptorIndex].tex; + sampler sampler = samplerHeap[samplerDescriptorIndex].samp; return texture.sample(sampler, texCoord); } -float4 tfetchCube(constant TextureCubeDescriptorHeap& textureHeap, - constant SamplerDescriptorHeap& samplerHeap, +float4 tfetchCube(constant TextureCubeDescriptorHeap* textureHeap, + constant SamplerDescriptorHeap* samplerHeap, uint resourceDescriptorIndex, uint samplerDescriptorIndex, float3 texCoord, thread CubeMapData* cubeMapData) { - texturecube texture = textureHeap.g[resourceDescriptorIndex]; - sampler sampler = samplerHeap.g[samplerDescriptorIndex]; + texturecube texture = textureHeap[resourceDescriptorIndex].tex; + sampler sampler = samplerHeap[samplerDescriptorIndex].samp; return texture.sample(sampler, cubeMapData->cubeMapDirections[(uint)texCoord.z]); } @@ -406,11 +406,11 @@ float4 max4(float4 src0) #ifdef __air__ -float2 getPixelCoord(constant Texture2DDescriptorHeap& textureHeap, +float2 getPixelCoord(constant Texture2DDescriptorHeap* textureHeap, uint resourceDescriptorIndex, float2 texCoord) { - texture2d texture = textureHeap.g[resourceDescriptorIndex]; + texture2d texture = textureHeap[resourceDescriptorIndex].tex; return (float2)getTexture2DDimensions(texture) * texCoord; } diff --git a/XenosRecomp/shader_recompiler.cpp b/XenosRecomp/shader_recompiler.cpp index 7902ffb..f9278ab 100644 --- a/XenosRecomp/shader_recompiler.cpp +++ b/XenosRecomp/shader_recompiler.cpp @@ -1683,10 +1683,10 @@ void ShaderRecompiler::recompile(const uint8_t* shaderData, const std::string_vi out += "\tfloat4 iPos [[position]],\n"; out += "\tbool iFace [[front_facing]],\n"; - out += "\tconstant Texture2DDescriptorHeap& g_Texture2DDescriptorHeap [[buffer(0)]],\n"; - out += "\tconstant Texture3DDescriptorHeap& g_Texture3DDescriptorHeap [[buffer(1)]],\n"; - out += "\tconstant TextureCubeDescriptorHeap& g_TextureCubeDescriptorHeap [[buffer(2)]],\n"; - out += "\tconstant SamplerDescriptorHeap& g_SamplerDescriptorHeap [[buffer(3)]],\n"; + out += "\tconstant Texture2DDescriptorHeap* g_Texture2DDescriptorHeap [[buffer(0)]],\n"; + out += "\tconstant Texture3DDescriptorHeap* g_Texture3DDescriptorHeap [[buffer(1)]],\n"; + out += "\tconstant TextureCubeDescriptorHeap* g_TextureCubeDescriptorHeap [[buffer(2)]],\n"; + out += "\tconstant SamplerDescriptorHeap* g_SamplerDescriptorHeap [[buffer(3)]],\n"; out += "\tconstant PushConstants& g_PushConstants [[buffer(4)]]\n"; out += "#else\n";