Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change primitiveCount to vertexCount #136

Merged
merged 4 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions include/SDL3/SDL_gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -1544,7 +1544,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_GpuBindFragmentStorageBuffers(
* \param renderPass a render pass handle
* \param baseVertex the starting offset to read from the vertex buffer
* \param startIndex the starting offset to read from the index buffer
* \param primitiveCount the number of primitives to draw
* \param vertexCount the number of vertices to draw
* \param instanceCount the number of instances that will be drawn
*
* \since This function is available since SDL 3.x.x
Expand All @@ -1553,7 +1553,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_GpuDrawIndexedPrimitives(
SDL_GpuRenderPass *renderPass,
Uint32 baseVertex,
Uint32 startIndex,
Uint32 primitiveCount,
Uint32 vertexCount,
Uint32 instanceCount);

/**
Expand All @@ -1562,14 +1562,14 @@ extern SDL_DECLSPEC void SDLCALL SDL_GpuDrawIndexedPrimitives(
*
* \param renderPass a render pass handle
* \param vertexStart The starting offset to read from the vertex buffer
* \param primitiveCount The number of primitives to draw
* \param vertexCount The number of vertices to draw
*
* \since This function is available since SDL 3.x.x
*/
extern SDL_DECLSPEC void SDLCALL SDL_GpuDrawPrimitives(
SDL_GpuRenderPass *renderPass,
Uint32 vertexStart,
Uint32 primitiveCount);
Uint32 vertexCount);

/**
* Draws data using bound graphics state and with draw parameters set from a buffer.
Expand Down
8 changes: 4 additions & 4 deletions src/gpu/SDL_gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ void SDL_GpuDrawIndexedPrimitives(
SDL_GpuRenderPass *renderPass,
Uint32 baseVertex,
Uint32 startIndex,
Uint32 primitiveCount,
Uint32 vertexCount,
Uint32 instanceCount)
{
if (renderPass == NULL) {
Expand All @@ -1129,14 +1129,14 @@ void SDL_GpuDrawIndexedPrimitives(
RENDERPASS_COMMAND_BUFFER,
baseVertex,
startIndex,
primitiveCount,
vertexCount,
instanceCount);
}

void SDL_GpuDrawPrimitives(
SDL_GpuRenderPass *renderPass,
Uint32 vertexStart,
Uint32 primitiveCount)
Uint32 vertexCount)
{
if (renderPass == NULL) {
SDL_InvalidParamError("renderPass");
Expand All @@ -1151,7 +1151,7 @@ void SDL_GpuDrawPrimitives(
RENDERPASS_DEVICE->DrawPrimitives(
RENDERPASS_COMMAND_BUFFER,
vertexStart,
primitiveCount);
vertexCount);
}

void SDL_GpuDrawPrimitivesIndirect(
Expand Down
25 changes: 2 additions & 23 deletions src/gpu/SDL_sysgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,27 +118,6 @@ static inline SDL_bool IsStencilFormat(
}
}

static inline Uint32 PrimitiveVerts(
SDL_GpuPrimitiveType primitiveType,
Uint32 primitiveCount)
{
switch (primitiveType) {
case SDL_GPU_PRIMITIVETYPE_TRIANGLELIST:
return primitiveCount * 3;
case SDL_GPU_PRIMITIVETYPE_TRIANGLESTRIP:
return primitiveCount + 2;
case SDL_GPU_PRIMITIVETYPE_LINELIST:
return primitiveCount * 2;
case SDL_GPU_PRIMITIVETYPE_LINESTRIP:
return primitiveCount + 1;
case SDL_GPU_PRIMITIVETYPE_POINTLIST:
return primitiveCount;
default:
SDL_assert_release(!"Unrecognized primitive type!");
return 0;
}
}

static inline Uint32 IndexSize(SDL_GpuIndexElementSize size)
{
return (size == SDL_GPU_INDEXELEMENTSIZE_16BIT) ? 2 : 4;
Expand Down Expand Up @@ -369,13 +348,13 @@ struct SDL_GpuDevice
SDL_GpuCommandBuffer *commandBuffer,
Uint32 baseVertex,
Uint32 startIndex,
Uint32 primitiveCount,
Uint32 vertexCount,
Uint32 instanceCount);

void (*DrawPrimitives)(
SDL_GpuCommandBuffer *commandBuffer,
Uint32 vertexStart,
Uint32 primitiveCount);
Uint32 vertexCount);

void (*DrawPrimitivesIndirect)(
SDL_GpuCommandBuffer *commandBuffer,
Expand Down
8 changes: 4 additions & 4 deletions src/gpu/d3d11/SDL_gpu_d3d11.c
Original file line number Diff line number Diff line change
Expand Up @@ -4098,15 +4098,15 @@ static void D3D11_DrawIndexedPrimitives(
SDL_GpuCommandBuffer *commandBuffer,
Uint32 baseVertex,
Uint32 startIndex,
Uint32 primitiveCount,
Uint32 vertexCount,
Uint32 instanceCount)
{
D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer;
D3D11_INTERNAL_BindGraphicsResources(d3d11CommandBuffer);

ID3D11DeviceContext_DrawIndexedInstanced(
d3d11CommandBuffer->context,
PrimitiveVerts(d3d11CommandBuffer->graphicsPipeline->primitiveType, primitiveCount),
vertexCount,
instanceCount,
startIndex,
baseVertex,
Expand All @@ -4116,14 +4116,14 @@ static void D3D11_DrawIndexedPrimitives(
static void D3D11_DrawPrimitives(
SDL_GpuCommandBuffer *commandBuffer,
Uint32 vertexStart,
Uint32 primitiveCount)
Uint32 vertexCount)
{
D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer;
D3D11_INTERNAL_BindGraphicsResources(d3d11CommandBuffer);

ID3D11DeviceContext_Draw(
d3d11CommandBuffer->context,
PrimitiveVerts(d3d11CommandBuffer->graphicsPipeline->primitiveType, primitiveCount),
vertexCount,
vertexStart);
}

Expand Down
8 changes: 4 additions & 4 deletions src/gpu/d3d12/SDL_gpu_d3d12.c
Original file line number Diff line number Diff line change
Expand Up @@ -4083,15 +4083,15 @@ static void D3D12_DrawIndexedPrimitives(
SDL_GpuCommandBuffer *commandBuffer,
Uint32 baseVertex,
Uint32 startIndex,
Uint32 primitiveCount,
Uint32 vertexCount,
Uint32 instanceCount)
{
D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer;
D3D12_INTERNAL_BindGraphicsResources(d3d12CommandBuffer);

ID3D12GraphicsCommandList_DrawIndexedInstanced(
d3d12CommandBuffer->graphicsCommandList,
PrimitiveVerts(d3d12CommandBuffer->currentGraphicsPipeline->primitiveType, primitiveCount),
vertexCount,
instanceCount,
startIndex,
baseVertex,
Expand All @@ -4101,14 +4101,14 @@ static void D3D12_DrawIndexedPrimitives(
static void D3D12_DrawPrimitives(
SDL_GpuCommandBuffer *commandBuffer,
Uint32 vertexStart,
Uint32 primitiveCount)
Uint32 vertexCount)
{
D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer;
D3D12_INTERNAL_BindGraphicsResources(d3d12CommandBuffer);

ID3D12GraphicsCommandList_DrawInstanced(
d3d12CommandBuffer->graphicsCommandList,
PrimitiveVerts(d3d12CommandBuffer->currentGraphicsPipeline->primitiveType, primitiveCount),
vertexCount,
1, /* Instance count */
vertexStart,
0 /* Start instance location */
Expand Down
8 changes: 4 additions & 4 deletions src/gpu/metal/SDL_gpu_metal.m
Original file line number Diff line number Diff line change
Expand Up @@ -2691,7 +2691,7 @@ static void METAL_DrawIndexedPrimitives(
SDL_GpuCommandBuffer *commandBuffer,
Uint32 baseVertex,
Uint32 startIndex,
Uint32 primitiveCount,
Uint32 vertexCount,
Uint32 instanceCount)
{
@autoreleasepool {
Expand All @@ -2703,7 +2703,7 @@ static void METAL_DrawIndexedPrimitives(

[metalCommandBuffer->renderEncoder
drawIndexedPrimitives:SDLToMetal_PrimitiveType[primitiveType]
indexCount:PrimitiveVerts(primitiveType, primitiveCount)
indexCount:vertexCount
indexType:SDLToMetal_IndexType[metalCommandBuffer->indexElementSize]
indexBuffer:metalCommandBuffer->indexBuffer->handle
indexBufferOffset:metalCommandBuffer->indexBufferOffset + (startIndex * indexSize)
Expand All @@ -2716,7 +2716,7 @@ static void METAL_DrawIndexedPrimitives(
static void METAL_DrawPrimitives(
SDL_GpuCommandBuffer *commandBuffer,
Uint32 vertexStart,
Uint32 primitiveCount)
Uint32 vertexCount)
{
@autoreleasepool {
MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer;
Expand All @@ -2727,7 +2727,7 @@ static void METAL_DrawPrimitives(
[metalCommandBuffer->renderEncoder
drawPrimitives:SDLToMetal_PrimitiveType[primitiveType]
vertexStart:vertexStart
vertexCount:PrimitiveVerts(primitiveType, primitiveCount)];
vertexCount:vertexCount];
}
}

Expand Down
12 changes: 4 additions & 8 deletions src/gpu/vulkan/SDL_gpu_vulkan.c
Original file line number Diff line number Diff line change
Expand Up @@ -5290,7 +5290,7 @@ static void VULKAN_DrawIndexedPrimitives(
SDL_GpuCommandBuffer *commandBuffer,
Uint32 baseVertex,
Uint32 startIndex,
Uint32 primitiveCount,
Uint32 vertexCount,
Uint32 instanceCount)
{
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer;
Expand All @@ -5300,9 +5300,7 @@ static void VULKAN_DrawIndexedPrimitives(

renderer->vkCmdDrawIndexed(
vulkanCommandBuffer->commandBuffer,
PrimitiveVerts(
vulkanCommandBuffer->currentGraphicsPipeline->primitiveType,
primitiveCount),
vertexCount,
instanceCount,
startIndex,
baseVertex,
Expand All @@ -5312,7 +5310,7 @@ static void VULKAN_DrawIndexedPrimitives(
static void VULKAN_DrawPrimitives(
SDL_GpuCommandBuffer *commandBuffer,
Uint32 vertexStart,
Uint32 primitiveCount)
Uint32 vertexCount)
{
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer;
VulkanRenderer *renderer = (VulkanRenderer *)vulkanCommandBuffer->renderer;
Expand All @@ -5321,9 +5319,7 @@ static void VULKAN_DrawPrimitives(

renderer->vkCmdDraw(
vulkanCommandBuffer->commandBuffer,
PrimitiveVerts(
vulkanCommandBuffer->currentGraphicsPipeline->primitiveType,
primitiveCount),
vertexCount,
1,
vertexStart,
0);
Expand Down
Loading