Skip to content

Commit

Permalink
metal renderer: use the device address space instead of the constant …
Browse files Browse the repository at this point in the history
…address space for colors.

It doesn't negatively impact GPU performance in my tests, and it removes the need for 256 byte memory alignment of color data on macOS.
  • Loading branch information
slime73 committed Aug 17, 2019
1 parent 3fb5cab commit e5acccc
Show file tree
Hide file tree
Showing 5 changed files with 1,516 additions and 1,512 deletions.
2 changes: 1 addition & 1 deletion src/render/metal/SDL_render_metal.m
Expand Up @@ -962,7 +962,7 @@ - (void)dealloc
METAL_QueueSetDrawColor(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
{
const size_t vertlen = sizeof (float) * 4;
float *verts = (float *) SDL_AllocateRenderVertices(renderer, vertlen, CONSTANT_ALIGN, &cmd->data.color.first);
float *verts = (float *) SDL_AllocateRenderVertices(renderer, vertlen, 16, &cmd->data.color.first);
if (!verts) {
return -1;
}
Expand Down
10 changes: 5 additions & 5 deletions src/render/metal/SDL_shaders_metal.metal
Expand Up @@ -20,7 +20,7 @@ vertex SolidVertexOutput SDL_Solid_vertex(const device float2 *position [[buffer
return v;
}

fragment float4 SDL_Solid_fragment(constant float4 &col [[buffer(0)]])
fragment float4 SDL_Solid_fragment(const device float4 &col [[buffer(0)]])
{
return col;
}
Expand All @@ -44,7 +44,7 @@ vertex CopyVertexOutput SDL_Copy_vertex(const device float2 *position [[buffer(0
}

fragment float4 SDL_Copy_fragment(CopyVertexOutput vert [[stage_in]],
constant float4 &col [[buffer(0)]],
const device float4 &col [[buffer(0)]],
texture2d<float> tex [[texture(0)]],
sampler s [[sampler(0)]])
{
Expand All @@ -60,7 +60,7 @@ struct YUVDecode
};

fragment float4 SDL_YUV_fragment(CopyVertexOutput vert [[stage_in]],
constant float4 &col [[buffer(0)]],
const device float4 &col [[buffer(0)]],
constant YUVDecode &decode [[buffer(1)]],
texture2d<float> texY [[texture(0)]],
texture2d_array<float> texUV [[texture(1)]],
Expand All @@ -77,7 +77,7 @@ fragment float4 SDL_YUV_fragment(CopyVertexOutput vert [[stage_in]],
}

fragment float4 SDL_NV12_fragment(CopyVertexOutput vert [[stage_in]],
constant float4 &col [[buffer(0)]],
const device float4 &col [[buffer(0)]],
constant YUVDecode &decode [[buffer(1)]],
texture2d<float> texY [[texture(0)]],
texture2d<float> texUV [[texture(1)]],
Expand All @@ -93,7 +93,7 @@ fragment float4 SDL_NV12_fragment(CopyVertexOutput vert [[stage_in]],
}

fragment float4 SDL_NV21_fragment(CopyVertexOutput vert [[stage_in]],
constant float4 &col [[buffer(0)]],
const device float4 &col [[buffer(0)]],
constant YUVDecode &decode [[buffer(1)]],
texture2d<float> texY [[texture(0)]],
texture2d<float> texUV [[texture(1)]],
Expand Down

0 comments on commit e5acccc

Please sign in to comment.