Helper Shader fixes for non float formats

This commit is contained in:
Isaac Marovitz
2024-08-01 00:37:37 +01:00
committed by Evan Husted
parent 80bb95dfb9
commit 68146fa285
5 changed files with 166 additions and 31 deletions

View File

@@ -7,12 +7,36 @@ struct CopyVertexOut {
float2 uv;
};
struct Textures
{
texture2d_ms<float, access::read> texture;
struct TexCoords {
float data[4];
};
fragment float4 fragmentMain(CopyVertexOut in [[stage_in]],
struct ConstantBuffers {
constant TexCoords* tex_coord;
};
struct Textures
{
texture2d_ms<FORMAT, access::read> texture;
};
vertex CopyVertexOut vertexMain(uint vid [[vertex_id]],
constant ConstantBuffers &constant_buffers [[buffer(CONSTANT_BUFFERS_INDEX)]]) {
CopyVertexOut out;
int low = vid & 1;
int high = vid >> 1;
out.uv.x = constant_buffers.tex_coord->data[low];
out.uv.y = constant_buffers.tex_coord->data[2 + high];
out.position.x = (float(low) - 0.5f) * 2.0f;
out.position.y = (float(high) - 0.5f) * 2.0f;
out.position.z = 0.0f;
out.position.w = 1.0f;
return out;
}
fragment FORMAT4 fragmentMain(CopyVertexOut in [[stage_in]],
constant Textures &textures [[buffer(TEXTURES_INDEX)]],
uint sample_id [[sample_id]]) {
uint2 tex_size = uint2(textures.texture.get_width(), textures.texture.get_height());