Use Tier 2 Arg Buffers

Signed-off-by: Isaac Marovitz <isaacryu@icloud.com>
This commit is contained in:
Isaac Marovitz 2025-04-11 21:39:11 -04:00
parent 2872dbb743
commit b931eafa55
No known key found for this signature in database
GPG key ID: 97250B2B09A132E1
12 changed files with 56 additions and 56 deletions

View file

@ -12,12 +12,12 @@ struct Interpolators
[[fragment]] [[fragment]]
float4 shaderMain(float4 iPos [[position]], float4 shaderMain(float4 iPos [[position]],
Interpolators input [[stage_in]], Interpolators input [[stage_in]],
constant Texture2DDescriptorHeap& g_Texture2DDescriptorHeap [[buffer(0)]], constant Texture2DDescriptorHeap* g_Texture2DDescriptorHeap [[buffer(0)]],
constant SamplerDescriptorHeap& g_SamplerDescriptorHeap [[buffer(3)]], constant SamplerDescriptorHeap* g_SamplerDescriptorHeap [[buffer(3)]],
constant PushConstants& g_PushConstants [[buffer(4)]]) constant PushConstants& g_PushConstants [[buffer(4)]])
{ {
texture2d<float> texture = g_Texture2DDescriptorHeap.g[s0_Texture2DDescriptorIndex]; texture2d<float> texture = g_Texture2DDescriptorHeap[s0_Texture2DDescriptorIndex].tex;
sampler samplerState = g_SamplerDescriptorHeap.g[s0_SamplerDescriptorIndex]; sampler samplerState = g_SamplerDescriptorHeap[s0_SamplerDescriptorIndex].samp;
float4 color = texture.sample(samplerState, input.iTexCoord0.xy); float4 color = texture.sample(samplerState, input.iTexCoord0.xy);

View file

@ -2,13 +2,13 @@
struct Texture2DDescriptorHeap struct Texture2DDescriptorHeap
{ {
array<texture2d<float>, 1> g [[id(0)]]; texture2d<float> tex;
}; };
[[fragment]] [[fragment]]
float4 shaderMain(float4 position [[position]], float4 shaderMain(float4 position [[position]],
constant Texture2DDescriptorHeap& g_Texture2DDescriptorHeap [[buffer(0)]], constant Texture2DDescriptorHeap* g_Texture2DDescriptorHeap [[buffer(0)]],
constant PushConstants& g_PushConstants [[buffer(4)]]) constant PushConstants& g_PushConstants [[buffer(4)]])
{ {
return g_Texture2DDescriptorHeap.g[g_PushConstants.ResourceDescriptorIndex].read(uint2(position.xy), 0); return g_Texture2DDescriptorHeap[g_PushConstants.ResourceDescriptorIndex].tex.read(uint2(position.xy), 0);
} }

View file

@ -2,7 +2,7 @@
struct Texture2DDescriptorHeap struct Texture2DDescriptorHeap
{ {
array<texture2d<float>, 1> g [[id(0)]]; texture2d<float> tex;
}; };
struct PixelShaderOutput struct PixelShaderOutput
@ -12,12 +12,12 @@ struct PixelShaderOutput
[[fragment]] [[fragment]]
PixelShaderOutput shaderMain(float4 position [[position]], PixelShaderOutput shaderMain(float4 position [[position]],
constant Texture2DDescriptorHeap& g_Texture2DDescriptorHeap [[buffer(0)]], constant Texture2DDescriptorHeap* g_Texture2DDescriptorHeap [[buffer(0)]],
constant PushConstants& g_PushConstants [[buffer(4)]]) constant PushConstants& g_PushConstants [[buffer(4)]])
{ {
PixelShaderOutput output = PixelShaderOutput{}; PixelShaderOutput output = PixelShaderOutput{};
output.oDepth = g_Texture2DDescriptorHeap.g[g_PushConstants.ResourceDescriptorIndex].read(uint2(position.xy), 0).x; output.oDepth = g_Texture2DDescriptorHeap[g_PushConstants.ResourceDescriptorIndex].tex.read(uint2(position.xy), 0).x;
return output; return output;
} }

View file

@ -12,12 +12,12 @@ struct Interpolators
[[fragment]] [[fragment]]
float4 shaderMain(Interpolators input [[stage_in]], float4 shaderMain(Interpolators input [[stage_in]],
constant Texture2DDescriptorHeap& g_Texture2DDescriptorHeap [[buffer(0)]], constant Texture2DDescriptorHeap* g_Texture2DDescriptorHeap [[buffer(0)]],
constant SamplerDescriptorHeap& g_SamplerDescriptorHeap [[buffer(3)]], constant SamplerDescriptorHeap* g_SamplerDescriptorHeap [[buffer(3)]],
constant PushConstants& g_PushConstants [[buffer(4)]]) constant PushConstants& g_PushConstants [[buffer(4)]])
{ {
texture2d<float> texture = g_Texture2DDescriptorHeap.g[s0_Texture2DDescriptorIndex]; texture2d<float> texture = g_Texture2DDescriptorHeap[s0_Texture2DDescriptorIndex].tex;
sampler samplerState = g_SamplerDescriptorHeap.g[s0_SamplerDescriptorIndex]; sampler samplerState = g_SamplerDescriptorHeap[s0_SamplerDescriptorIndex].samp;
uint2 dimensions = getTexture2DDimensions(texture); uint2 dimensions = getTexture2DDimensions(texture);

View file

@ -20,17 +20,17 @@ struct Interpolators
[[fragment]] [[fragment]]
float4 shaderMain(float4 position [[position]], float4 shaderMain(float4 position [[position]],
Interpolators input [[stage_in]], Interpolators input [[stage_in]],
constant Texture2DDescriptorHeap& g_Texture2DDescriptorHeap [[buffer(0)]], constant Texture2DDescriptorHeap* g_Texture2DDescriptorHeap [[buffer(0)]],
constant SamplerDescriptorHeap& g_SamplerDescriptorHeap [[buffer(3)]], constant SamplerDescriptorHeap* g_SamplerDescriptorHeap [[buffer(3)]],
constant PushConstants& g_PushConstants [[buffer(4)]]) constant PushConstants& g_PushConstants [[buffer(4)]])
{ {
texture2d<float> sampColor = g_Texture2DDescriptorHeap.g[sampColor_Texture2DDescriptorIndex]; texture2d<float> sampColor = g_Texture2DDescriptorHeap[sampColor_Texture2DDescriptorIndex].tex;
texture2d<float> sampVelocityMap = g_Texture2DDescriptorHeap.g[sampVelocityMap_Texture2DDescriptorIndex]; texture2d<float> sampVelocityMap = g_Texture2DDescriptorHeap[sampVelocityMap_Texture2DDescriptorIndex].tex;
texture2d<float> sampZBuffer = g_Texture2DDescriptorHeap.g[sampZBuffer_Texture2DDescriptorIndex]; texture2d<float> sampZBuffer = g_Texture2DDescriptorHeap[sampZBuffer_Texture2DDescriptorIndex].tex;
sampler sampColor_s = g_SamplerDescriptorHeap.g[sampColor_SamplerDescriptorIndex]; sampler sampColor_s = g_SamplerDescriptorHeap[sampColor_SamplerDescriptorIndex].samp;
sampler sampVelocityMap_s = g_SamplerDescriptorHeap.g[sampVelocityMap_SamplerDescriptorIndex]; sampler sampVelocityMap_s = g_SamplerDescriptorHeap[sampVelocityMap_SamplerDescriptorIndex].samp;
sampler sampZBuffer_s = g_SamplerDescriptorHeap.g[sampZBuffer_SamplerDescriptorIndex]; sampler sampZBuffer_s = g_SamplerDescriptorHeap[sampZBuffer_SamplerDescriptorIndex].samp;
float depth = sampZBuffer.sample(sampZBuffer_s, input.texCoord.xy, level(0)).x; float depth = sampZBuffer.sample(sampZBuffer_s, input.texCoord.xy, level(0)).x;
float4 velocityMap = sampVelocityMap.sample(sampVelocityMap_s, input.texCoord.xy, level(0)); float4 velocityMap = sampVelocityMap.sample(sampVelocityMap_s, input.texCoord.xy, level(0));

View file

@ -8,10 +8,10 @@
[[fragment]] [[fragment]]
float4 shaderMain(float4 position [[position]], float4 shaderMain(float4 position [[position]],
constant Texture2DDescriptorHeap& g_Texture2DDescriptorHeap [[buffer(0)]], constant Texture2DDescriptorHeap* g_Texture2DDescriptorHeap [[buffer(0)]],
constant PushConstants& g_PushConstants [[buffer(4)]]) constant PushConstants& g_PushConstants [[buffer(4)]])
{ {
texture2d<float> texture = g_Texture2DDescriptorHeap.g[g_TextureDescriptorIndex]; texture2d<float> texture = g_Texture2DDescriptorHeap[g_TextureDescriptorIndex].tex;
int2 movedPosition = int2(position.xy) - g_ViewportOffset; int2 movedPosition = int2(position.xy) - g_ViewportOffset;
bool boxed = any(movedPosition < 0) || any(movedPosition >= g_ViewportSize); bool boxed = any(movedPosition < 0) || any(movedPosition >= g_ViewportSize);

View file

@ -27,12 +27,12 @@ struct Interpolators
[[fragment]] [[fragment]]
float4 shaderMain(float4 iPosition [[position]], float4 shaderMain(float4 iPosition [[position]],
Interpolators input [[stage_in]], Interpolators input [[stage_in]],
constant Texture2DDescriptorHeap& g_Texture2DDescriptorHeap [[buffer(0)]], constant Texture2DDescriptorHeap* g_Texture2DDescriptorHeap [[buffer(0)]],
constant SamplerDescriptorHeap& g_SamplerDescriptorHeap [[buffer(3)]], constant SamplerDescriptorHeap* g_SamplerDescriptorHeap [[buffer(3)]],
constant PushConstants& g_PushConstants [[buffer(4)]]) constant PushConstants& g_PushConstants [[buffer(4)]])
{ {
texture2d<float> texture = g_Texture2DDescriptorHeap.g[s0_Texture2DDescriptorIndex]; texture2d<float> texture = g_Texture2DDescriptorHeap[s0_Texture2DDescriptorIndex].tex;
sampler samplerState = g_SamplerDescriptorHeap.g[s0_SamplerDescriptorIndex]; sampler samplerState = g_SamplerDescriptorHeap[s0_SamplerDescriptorIndex].samp;
float scale; float scale;
if ((g_ViewportSize.x * g_ViewportSize.w) >= (16.0 / 9.0)) if ((g_ViewportSize.x * g_ViewportSize.w) >= (16.0 / 9.0))

View file

@ -32,10 +32,10 @@ struct Interpolators
struct Texture2DDescriptorHeap struct Texture2DDescriptorHeap
{ {
array<texture2d<float>, 1> g [[id(0)]]; texture2d<float> tex;
}; };
struct SamplerDescriptorHeap struct SamplerDescriptorHeap
{ {
array<sampler, 1> g [[id(0)]]; sampler samp;
}; };

View file

@ -79,10 +79,10 @@ float median(float r, float g, float b)
} }
float4 SampleSdfFont(float4 color, texture2d<float> texture, float2 uv, float2 screenTexSize, float4 SampleSdfFont(float4 color, texture2d<float> texture, float2 uv, float2 screenTexSize,
constant SamplerDescriptorHeap& g_SamplerDescriptorHeap, constant SamplerDescriptorHeap* g_SamplerDescriptorHeap,
constant PushConstants& g_PushConstants) constant PushConstants& g_PushConstants)
{ {
float4 textureColor = texture.sample(g_SamplerDescriptorHeap.g[0], uv); float4 textureColor = texture.sample(g_SamplerDescriptorHeap[0].samp, uv);
uint width = texture.get_width(); uint width = texture.get_width();
uint height = texture.get_height(); uint height = texture.get_height();
@ -127,8 +127,8 @@ float4 SampleSdfFont(float4 color, texture2d<float> texture, float2 uv, float2 s
[[fragment]] [[fragment]]
float4 shaderMain(Interpolators interpolators [[stage_in]], float4 shaderMain(Interpolators interpolators [[stage_in]],
constant Texture2DDescriptorHeap& g_Texture2DDescriptorHeap [[buffer(0)]], constant Texture2DDescriptorHeap* g_Texture2DDescriptorHeap [[buffer(0)]],
constant SamplerDescriptorHeap& g_SamplerDescriptorHeap [[buffer(1)]], constant SamplerDescriptorHeap* g_SamplerDescriptorHeap [[buffer(1)]],
constant PushConstants& g_PushConstants [[buffer(4)]]) constant PushConstants& g_PushConstants [[buffer(4)]])
{ {
float4 color = interpolators.Color; float4 color = interpolators.Color;
@ -136,7 +136,7 @@ float4 shaderMain(Interpolators interpolators [[stage_in]],
if (g_PushConstants.Texture2DDescriptorIndex != 0) if (g_PushConstants.Texture2DDescriptorIndex != 0)
{ {
texture2d<float> texture = g_Texture2DDescriptorHeap.g[g_PushConstants.Texture2DDescriptorIndex & 0x7FFFFFFF]; texture2d<float> texture = g_Texture2DDescriptorHeap[g_PushConstants.Texture2DDescriptorIndex & 0x7FFFFFFF].tex;
if ((g_PushConstants.Texture2DDescriptorIndex & 0x80000000) != 0) if ((g_PushConstants.Texture2DDescriptorIndex & 0x80000000) != 0)
{ {
@ -180,7 +180,7 @@ float4 shaderMain(Interpolators interpolators [[stage_in]],
} }
else else
{ {
color *= texture.sample(g_SamplerDescriptorHeap.g[0], interpolators.UV); color *= texture.sample(g_SamplerDescriptorHeap[0].samp, interpolators.UV);
} }
} }

View file

@ -2,21 +2,21 @@
[[fragment]] [[fragment]]
PixelShaderOutput shaderMain(Interpolators In [[stage_in]], PixelShaderOutput shaderMain(Interpolators In [[stage_in]],
constant Texture2DDescriptorHeap& g_Texture2DDescriptorHeap [[buffer(0)]], constant Texture2DDescriptorHeap* g_Texture2DDescriptorHeap [[buffer(0)]],
constant SamplerDescriptorHeap& g_SamplerDescriptorHeap [[buffer(3)]], constant SamplerDescriptorHeap* g_SamplerDescriptorHeap [[buffer(3)]],
constant PushConstants& g_PushConstants [[buffer(4)]]) constant PushConstants& g_PushConstants [[buffer(4)]])
{ {
texture2d<float> Tex0 = g_Texture2DDescriptorHeap.g[Tex0_ResourceDescriptorIndex]; texture2d<float> Tex0 = g_Texture2DDescriptorHeap[Tex0_ResourceDescriptorIndex].tex;
texture2d<float> Tex1 = g_Texture2DDescriptorHeap.g[Tex1_ResourceDescriptorIndex]; texture2d<float> Tex1 = g_Texture2DDescriptorHeap[Tex1_ResourceDescriptorIndex].tex;
texture2d<float> Tex2 = g_Texture2DDescriptorHeap.g[Tex2_ResourceDescriptorIndex]; texture2d<float> Tex2 = g_Texture2DDescriptorHeap[Tex2_ResourceDescriptorIndex].tex;
texture2d<float> Tex3 = g_Texture2DDescriptorHeap.g[Tex3_ResourceDescriptorIndex]; texture2d<float> Tex3 = g_Texture2DDescriptorHeap[Tex3_ResourceDescriptorIndex].tex;
texture2d<float> Tex4 = g_Texture2DDescriptorHeap.g[Tex4_ResourceDescriptorIndex]; texture2d<float> Tex4 = g_Texture2DDescriptorHeap[Tex4_ResourceDescriptorIndex].tex;
sampler Tex0_s = g_SamplerDescriptorHeap.g[Tex0_SamplerDescriptorIndex]; sampler Tex0_s = g_SamplerDescriptorHeap[Tex0_SamplerDescriptorIndex].samp;
sampler Tex1_s = g_SamplerDescriptorHeap.g[Tex1_SamplerDescriptorIndex]; sampler Tex1_s = g_SamplerDescriptorHeap[Tex1_SamplerDescriptorIndex].samp;
sampler Tex2_s = g_SamplerDescriptorHeap.g[Tex2_SamplerDescriptorIndex]; sampler Tex2_s = g_SamplerDescriptorHeap[Tex2_SamplerDescriptorIndex].samp;
sampler Tex3_s = g_SamplerDescriptorHeap.g[Tex3_SamplerDescriptorIndex]; sampler Tex3_s = g_SamplerDescriptorHeap[Tex3_SamplerDescriptorIndex].samp;
sampler Tex4_s = g_SamplerDescriptorHeap.g[Tex4_SamplerDescriptorIndex]; sampler Tex4_s = g_SamplerDescriptorHeap[Tex4_SamplerDescriptorIndex].samp;
PixelShaderOutput Out; PixelShaderOutput Out;
float ValY = Tex0.sample(Tex0_s, In.UV).r; float ValY = Tex0.sample(Tex0_s, In.UV).r;

View file

@ -4,18 +4,18 @@
struct Texture2DMSDescriptorHeap struct Texture2DMSDescriptorHeap
{ {
array<texture2d_ms<float>, 1> g [[id(0)]]; texture2d_ms<float> tex;
}; };
[[fragment]] [[fragment]]
float4 shaderMain(float4 position [[position]], float4 shaderMain(float4 position [[position]],
constant Texture2DMSDescriptorHeap& g_Texture2DMSDescriptorHeap [[buffer(0)]], constant Texture2DMSDescriptorHeap* g_Texture2DMSDescriptorHeap [[buffer(0)]],
constant PushConstants& g_PushConstants [[buffer(4)]]) constant PushConstants& g_PushConstants [[buffer(4)]])
{ {
float4 result = g_Texture2DMSDescriptorHeap.g[g_PushConstants.ResourceDescriptorIndex].read(uint2(position.xy), 0); float4 result = g_Texture2DMSDescriptorHeap[g_PushConstants.ResourceDescriptorIndex].tex.read(uint2(position.xy), 0);
for (int i = 1; i < SAMPLE_COUNT; i++) for (int i = 1; i < SAMPLE_COUNT; i++)
result += g_Texture2DMSDescriptorHeap.g[g_PushConstants.ResourceDescriptorIndex].read(uint2(position.xy), i); result += g_Texture2DMSDescriptorHeap[g_PushConstants.ResourceDescriptorIndex].tex.read(uint2(position.xy), i);
return result / SAMPLE_COUNT; return result / SAMPLE_COUNT;
} }

View file

@ -4,7 +4,7 @@
struct Texture2DMSDescriptorHeap struct Texture2DMSDescriptorHeap
{ {
array<texture2d_ms<float>, 1> g [[id(0)]]; texture2d_ms<float> tex;
}; };
struct PixelShaderOutput struct PixelShaderOutput
@ -14,15 +14,15 @@ struct PixelShaderOutput
[[fragment]] [[fragment]]
PixelShaderOutput shaderMain(float4 position [[position]], PixelShaderOutput shaderMain(float4 position [[position]],
constant Texture2DMSDescriptorHeap& g_Texture2DMSDescriptorHeap [[buffer(0)]], constant Texture2DMSDescriptorHeap* g_Texture2DMSDescriptorHeap [[buffer(0)]],
constant PushConstants& g_PushConstants [[buffer(4)]]) constant PushConstants& g_PushConstants [[buffer(4)]])
{ {
PixelShaderOutput output = PixelShaderOutput{}; PixelShaderOutput output = PixelShaderOutput{};
float result = g_Texture2DMSDescriptorHeap.g[g_PushConstants.ResourceDescriptorIndex].read(uint2(position.xy), 0).x; float result = g_Texture2DMSDescriptorHeap[g_PushConstants.ResourceDescriptorIndex].tex.read(uint2(position.xy), 0).x;
for (int i = 1; i < SAMPLE_COUNT; i++) for (int i = 1; i < SAMPLE_COUNT; i++)
result = min(result, g_Texture2DMSDescriptorHeap.g[g_PushConstants.ResourceDescriptorIndex].read(uint2(position.xy), i).x); result = min(result, g_Texture2DMSDescriptorHeap[g_PushConstants.ResourceDescriptorIndex].tex.read(uint2(position.xy), i).x);
output.oDepth = result; output.oDepth = result;