mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-21 12:59:14 +12:00
rewrite shaders
This commit is contained in:
parent
e0fcfb44a8
commit
d41e77491a
5 changed files with 52 additions and 18 deletions
|
@ -36,6 +36,13 @@ void RendererMTL::initGraphicsContext(SDL_Window* window) {
|
|||
device = MTL::CreateSystemDefaultDevice();
|
||||
metalLayer->setDevice(device);
|
||||
commandQueue = device->newCommandQueue();
|
||||
|
||||
// HACK
|
||||
MTL::TextureDescriptor* descriptor = MTL::TextureDescriptor::texture2DDescriptor(MTL::PixelFormatRGBA8Unorm, 400, 240, false);
|
||||
topScreenTexture = device->newTexture(descriptor);
|
||||
|
||||
// Pipelines
|
||||
// TODO
|
||||
}
|
||||
|
||||
void RendererMTL::clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) {
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
struct VertexOut {
|
||||
float4 position [[position]];
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
vertex VertexOut vertexMain(uint vid [[vertex_id]]) {
|
||||
VertexOut out;
|
||||
out.uv = float2((vid << 1) & 2, vid & 2);
|
||||
out.position = float4(out.uv * 2.0f + -1.0f, 0.0f, 1.0f);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
fragment float4 fragmentMain(VertexOut in [[stage_in]], texture2d<float> tex [[texture(0)]], sampler samplr [[sampler(0)]]) {
|
||||
return tex.sample(samplr, in.uv);
|
||||
}
|
36
src/host_shaders/metal_shaders.metal
Normal file
36
src/host_shaders/metal_shaders.metal
Normal file
|
@ -0,0 +1,36 @@
|
|||
struct DisplayVertexOut {
|
||||
float4 position [[position]];
|
||||
float2 uv;
|
||||
};
|
||||
|
||||
vertex DisplayVertexOut vertexDisplay(uint vid [[vertex_id]]) {
|
||||
DisplayVertexOut out;
|
||||
out.uv = float2((vid << 1) & 2, vid & 2);
|
||||
out.position = float4(out.uv * 2.0f + -1.0f, 0.0f, 1.0f);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
fragment float4 fragmentDisplay(DisplayVertexOut in [[stage_in]], texture2d<float> tex [[texture(0)]], sampler samplr [[sampler(0)]]) {
|
||||
return tex.sample(samplr, in.uv);
|
||||
}
|
||||
|
||||
struct DrawVertexIn {
|
||||
float4 position [[attribute(0)]];
|
||||
float4 color [[attribute(2)]];
|
||||
};
|
||||
|
||||
struct DrawVertexOut {
|
||||
float4 position [[position]];
|
||||
float4 color;
|
||||
};
|
||||
|
||||
vertex DrawVertexOut vertexDraw(DrawVertexIn in [[stage_in]]) {
|
||||
DrawVertexOut out;
|
||||
out.position = in.position;
|
||||
out.color = in.color;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
fragment float4 fragmentDraw(DrawVertexOut in [[stage_in]]) { return in.color; }
|
Loading…
Add table
Add a link
Reference in a new issue