Compare commits

...

2 commits

Author SHA1 Message Date
Isaac Marovitz
3646771956
Merge 01a0f4c0ae into 421e3b3e79 2025-04-12 01:40:02 +00:00
Isaac Marovitz
01a0f4c0ae
Use Tier 2 Arg Buffers
Signed-off-by: Isaac Marovitz <isaacryu@icloud.com>
2025-04-11 21:39:56 -04:00
2 changed files with 29 additions and 29 deletions

View file

@ -78,22 +78,22 @@ uint g_SpecConstants();
struct Texture2DDescriptorHeap struct Texture2DDescriptorHeap
{ {
array<texture2d<float>, 1> g [[id(0)]]; texture2d<float> tex;
}; };
struct Texture3DDescriptorHeap struct Texture3DDescriptorHeap
{ {
array<texture3d<float>, 1> g [[id(0)]]; texture3d<float> tex;
}; };
struct TextureCubeDescriptorHeap struct TextureCubeDescriptorHeap
{ {
array<texturecube<float>, 1> g [[id(0)]]; texturecube<float> tex;
}; };
struct SamplerDescriptorHeap struct SamplerDescriptorHeap
{ {
array<sampler, 1> g [[id(0)]]; sampler samp;
}; };
uint2 getTexture2DDimensions(texture2d<float> texture) uint2 getTexture2DDimensions(texture2d<float> texture)
@ -101,24 +101,24 @@ uint2 getTexture2DDimensions(texture2d<float> texture)
return uint2(texture.get_width(), texture.get_height()); return uint2(texture.get_width(), texture.get_height());
} }
float4 tfetch2D(constant Texture2DDescriptorHeap& textureHeap, float4 tfetch2D(constant Texture2DDescriptorHeap* textureHeap,
constant SamplerDescriptorHeap& samplerHeap, constant SamplerDescriptorHeap* samplerHeap,
uint resourceDescriptorIndex, uint resourceDescriptorIndex,
uint samplerDescriptorIndex, uint samplerDescriptorIndex,
float2 texCoord, float2 offset) float2 texCoord, float2 offset)
{ {
texture2d<float> texture = textureHeap.g[resourceDescriptorIndex]; texture2d<float> texture = textureHeap[resourceDescriptorIndex].tex;
sampler sampler = samplerHeap.g[samplerDescriptorIndex]; sampler sampler = samplerHeap[samplerDescriptorIndex].samp;
return texture.sample(sampler, texCoord + offset / (float2)getTexture2DDimensions(texture)); return texture.sample(sampler, texCoord + offset / (float2)getTexture2DDimensions(texture));
} }
float2 getWeights2D(constant Texture2DDescriptorHeap& textureHeap, float2 getWeights2D(constant Texture2DDescriptorHeap* textureHeap,
constant SamplerDescriptorHeap& samplerHeap, constant SamplerDescriptorHeap* samplerHeap,
uint resourceDescriptorIndex, uint resourceDescriptorIndex,
uint samplerDescriptorIndex, uint samplerDescriptorIndex,
float2 texCoord, float2 offset) float2 texCoord, float2 offset)
{ {
texture2d<float> texture = textureHeap.g[resourceDescriptorIndex]; texture2d<float> texture = textureHeap[resourceDescriptorIndex].tex;
return select(fract(texCoord * (float2)getTexture2DDimensions(texture) + offset - 0.5), 0.0, isnan(texCoord)); return select(fract(texCoord * (float2)getTexture2DDimensions(texture) + offset - 0.5), 0.0, isnan(texCoord));
} }
@ -236,14 +236,14 @@ struct CubeMapData
#ifdef __air__ #ifdef __air__
float4 tfetch2DBicubic(constant Texture2DDescriptorHeap& textureHeap, float4 tfetch2DBicubic(constant Texture2DDescriptorHeap* textureHeap,
constant SamplerDescriptorHeap& samplerHeap, constant SamplerDescriptorHeap* samplerHeap,
uint resourceDescriptorIndex, uint resourceDescriptorIndex,
uint samplerDescriptorIndex, uint samplerDescriptorIndex,
float2 texCoord, float2 offset) float2 texCoord, float2 offset)
{ {
texture2d<float> texture = textureHeap.g[resourceDescriptorIndex]; texture2d<float> texture = textureHeap[resourceDescriptorIndex].tex;
sampler sampler = samplerHeap.g[samplerDescriptorIndex]; sampler sampler = samplerHeap[samplerDescriptorIndex].samp;
uint2 dimensions = getTexture2DDimensions(texture); uint2 dimensions = getTexture2DDimensions(texture);
float x = texCoord.x * dimensions.x + offset.x; float x = texCoord.x * dimensions.x + offset.x;
@ -272,25 +272,25 @@ float4 tfetch2DBicubic(constant Texture2DDescriptorHeap& textureHeap,
return r; return r;
} }
float4 tfetch3D(constant Texture3DDescriptorHeap& textureHeap, float4 tfetch3D(constant Texture3DDescriptorHeap* textureHeap,
constant SamplerDescriptorHeap& samplerHeap, constant SamplerDescriptorHeap* samplerHeap,
uint resourceDescriptorIndex, uint resourceDescriptorIndex,
uint samplerDescriptorIndex, uint samplerDescriptorIndex,
float3 texCoord) float3 texCoord)
{ {
texture3d<float> texture = textureHeap.g[resourceDescriptorIndex]; texture3d<float> texture = textureHeap[resourceDescriptorIndex].tex;
sampler sampler = samplerHeap.g[samplerDescriptorIndex]; sampler sampler = samplerHeap[samplerDescriptorIndex].samp;
return texture.sample(sampler, texCoord); return texture.sample(sampler, texCoord);
} }
float4 tfetchCube(constant TextureCubeDescriptorHeap& textureHeap, float4 tfetchCube(constant TextureCubeDescriptorHeap* textureHeap,
constant SamplerDescriptorHeap& samplerHeap, constant SamplerDescriptorHeap* samplerHeap,
uint resourceDescriptorIndex, uint resourceDescriptorIndex,
uint samplerDescriptorIndex, uint samplerDescriptorIndex,
float3 texCoord, thread CubeMapData* cubeMapData) float3 texCoord, thread CubeMapData* cubeMapData)
{ {
texturecube<float> texture = textureHeap.g[resourceDescriptorIndex]; texturecube<float> texture = textureHeap[resourceDescriptorIndex].tex;
sampler sampler = samplerHeap.g[samplerDescriptorIndex]; sampler sampler = samplerHeap[samplerDescriptorIndex].samp;
return texture.sample(sampler, cubeMapData->cubeMapDirections[(uint)texCoord.z]); return texture.sample(sampler, cubeMapData->cubeMapDirections[(uint)texCoord.z]);
} }
@ -406,11 +406,11 @@ float4 max4(float4 src0)
#ifdef __air__ #ifdef __air__
float2 getPixelCoord(constant Texture2DDescriptorHeap& textureHeap, float2 getPixelCoord(constant Texture2DDescriptorHeap* textureHeap,
uint resourceDescriptorIndex, uint resourceDescriptorIndex,
float2 texCoord) float2 texCoord)
{ {
texture2d<float> texture = textureHeap.g[resourceDescriptorIndex]; texture2d<float> texture = textureHeap[resourceDescriptorIndex].tex;
return (float2)getTexture2DDimensions(texture) * texCoord; return (float2)getTexture2DDimensions(texture) * texCoord;
} }

View file

@ -1683,10 +1683,10 @@ void ShaderRecompiler::recompile(const uint8_t* shaderData, const std::string_vi
out += "\tfloat4 iPos [[position]],\n"; out += "\tfloat4 iPos [[position]],\n";
out += "\tbool iFace [[front_facing]],\n"; out += "\tbool iFace [[front_facing]],\n";
out += "\tconstant Texture2DDescriptorHeap& g_Texture2DDescriptorHeap [[buffer(0)]],\n"; out += "\tconstant Texture2DDescriptorHeap* g_Texture2DDescriptorHeap [[buffer(0)]],\n";
out += "\tconstant Texture3DDescriptorHeap& g_Texture3DDescriptorHeap [[buffer(1)]],\n"; out += "\tconstant Texture3DDescriptorHeap* g_Texture3DDescriptorHeap [[buffer(1)]],\n";
out += "\tconstant TextureCubeDescriptorHeap& g_TextureCubeDescriptorHeap [[buffer(2)]],\n"; out += "\tconstant TextureCubeDescriptorHeap* g_TextureCubeDescriptorHeap [[buffer(2)]],\n";
out += "\tconstant SamplerDescriptorHeap& g_SamplerDescriptorHeap [[buffer(3)]],\n"; out += "\tconstant SamplerDescriptorHeap* g_SamplerDescriptorHeap [[buffer(3)]],\n";
out += "\tconstant PushConstants& g_PushConstants [[buffer(4)]]\n"; out += "\tconstant PushConstants& g_PushConstants [[buffer(4)]]\n";
out += "#else\n"; out += "#else\n";