don't bind resources unnecessarily
This commit is contained in:
29
src/host_shaders/metal_blit.metal
Normal file
29
src/host_shaders/metal_blit.metal
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <metal_stdlib>
|
||||
using namespace metal;
|
||||
|
||||
#define GET_HELPER_TEXTURE_BINDING(binding) (30 - binding)
|
||||
#define GET_HELPER_SAMPLER_STATE_BINDING(binding) (15 - binding)
|
||||
|
||||
struct BasicVertexOut {
|
||||
float4 position [[position]];
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
struct NDCViewport {
|
||||
float2 offset;
|
||||
float2 scale;
|
||||
};
|
||||
|
||||
vertex BasicVertexOut vertexBlit(uint vid [[vertex_id]], constant NDCViewport& viewport [[buffer(0)]]) {
|
||||
BasicVertexOut out;
|
||||
out.uv = float2((vid << 1) & 2, vid & 2);
|
||||
out.position = float4(out.uv * 2.0 - 1.0, 0.0, 1.0);
|
||||
out.position.y = -out.position.y;
|
||||
out.uv = out.uv * viewport.scale + viewport.offset;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
fragment float4 fragmentBlit(BasicVertexOut in [[stage_in]], texture2d<float> tex [[texture(GET_HELPER_TEXTURE_BINDING(0))]], sampler samplr [[sampler(GET_HELPER_SAMPLER_STATE_BINDING(0))]]) {
|
||||
return tex.sample(samplr, in.uv);
|
||||
}
|
||||
@@ -32,25 +32,6 @@ fragment float4 fragmentDisplay(BasicVertexOut in [[stage_in]], texture2d<float>
|
||||
return tex.sample(samplr, in.uv);
|
||||
}
|
||||
|
||||
struct NDCViewport {
|
||||
float2 offset;
|
||||
float2 scale;
|
||||
};
|
||||
|
||||
vertex BasicVertexOut vertexBlit(uint vid [[vertex_id]], constant NDCViewport& viewport [[buffer(0)]]) {
|
||||
BasicVertexOut out;
|
||||
out.uv = float2((vid << 1) & 2, vid & 2);
|
||||
out.position = float4(out.uv * 2.0 - 1.0, 0.0, 1.0);
|
||||
out.position.y = -out.position.y;
|
||||
out.uv = out.uv * viewport.scale + viewport.offset;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
fragment float4 fragmentBlit(BasicVertexOut in [[stage_in]], texture2d<float> tex [[texture(0)]], sampler samplr [[sampler(0)]]) {
|
||||
return tex.sample(samplr, in.uv);
|
||||
}
|
||||
|
||||
struct PicaRegs {
|
||||
uint regs[0x200 - 0x48];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user