GPU: Rename struct members and parameters for SDL3 naming conventions (#10730)
--------- Co-authored-by: Evan Hemsley <2342303+thatcosmonaut@users.noreply.github.com>
This commit is contained in:
1 parent
e21f70c593
commit
9730f62e8c
13 files changed
+2963
-2972
No files matched your search
@@ -70,7 +70,7 @@ SDL_DYNAPI_PROC(SDL_JoystickID,SDL_AttachVirtualJoystick,(const SDL_VirtualJoyst
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_AudioDevicePaused,(SDL_AudioDeviceID a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_GPUComputePass*,SDL_BeginGPUComputePass,(SDL_GPUCommandBuffer *a, const SDL_GPUStorageTextureWriteOnlyBinding *b, Uint32 c, const SDL_GPUStorageBufferWriteOnlyBinding *d, Uint32 e),(a,b,c,d,e),return)
|
||||
SDL_DYNAPI_PROC(SDL_GPUCopyPass*,SDL_BeginGPUCopyPass,(SDL_GPUCommandBuffer *a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_GPURenderPass*,SDL_BeginGPURenderPass,(SDL_GPUCommandBuffer *a, const SDL_GPUColorAttachmentInfo *b, Uint32 c, const SDL_GPUDepthStencilAttachmentInfo *d),(a,b,c,d),return)
|
||||
SDL_DYNAPI_PROC(SDL_GPURenderPass*,SDL_BeginGPURenderPass,(SDL_GPUCommandBuffer *a, const SDL_GPUColorTargetInfo *b, Uint32 c, const SDL_GPUDepthStencilTargetInfo *d),(a,b,c,d),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_BindAudioStream,(SDL_AudioDeviceID a, SDL_AudioStream *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_BindAudioStreams,(SDL_AudioDeviceID a, SDL_AudioStream **b, int c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(void,SDL_BindGPUComputePipeline,(SDL_GPUComputePass *a, SDL_GPUComputePipeline *b),(a,b),)
|
||||
|
||||
+702
-702
File diff suppressed because it is too large.
Load diff
+58
-58
@@ -28,18 +28,18 @@
|
||||
|
||||
typedef struct Pass
|
||||
{
|
||||
SDL_GPUCommandBuffer *commandBuffer;
|
||||
bool inProgress;
|
||||
SDL_GPUCommandBuffer *command_buffer;
|
||||
bool in_progress;
|
||||
} Pass;
|
||||
|
||||
typedef struct CommandBufferCommonHeader
|
||||
{
|
||||
SDL_GPUDevice *device;
|
||||
Pass renderPass;
|
||||
bool graphicsPipelineBound;
|
||||
Pass computePass;
|
||||
bool computePipelineBound;
|
||||
Pass copyPass;
|
||||
Pass render_pass;
|
||||
bool graphics_pipeline_bound;
|
||||
Pass compute_pass;
|
||||
bool compute_pipeline_bound;
|
||||
Pass copy_pass;
|
||||
bool submitted;
|
||||
} CommandBufferCommonHeader;
|
||||
|
||||
@@ -56,8 +56,8 @@ typedef struct BlitFragmentUniforms
|
||||
float width;
|
||||
float height;
|
||||
|
||||
Uint32 mipLevel;
|
||||
float layerOrDepth;
|
||||
Uint32 mip_level;
|
||||
float layer_or_depth;
|
||||
} BlitFragmentUniforms;
|
||||
|
||||
typedef struct BlitPipelineCacheEntry
|
||||
@@ -266,7 +266,7 @@ void SDL_GPU_BlitCommon(
|
||||
const SDL_GPUBlitRegion *source,
|
||||
const SDL_GPUBlitRegion *destination,
|
||||
SDL_FlipMode flipMode,
|
||||
SDL_GPUFilter filterMode,
|
||||
SDL_GPUFilter filter,
|
||||
bool cycle,
|
||||
SDL_GPUSampler *blitLinearSampler,
|
||||
SDL_GPUSampler *blitNearestSampler,
|
||||
@@ -297,33 +297,33 @@ struct SDL_GPUDevice
|
||||
|
||||
SDL_GPUComputePipeline *(*CreateComputePipeline)(
|
||||
SDL_GPURenderer *driverData,
|
||||
const SDL_GPUComputePipelineCreateInfo *pipelineCreateInfo);
|
||||
const SDL_GPUComputePipelineCreateInfo *createinfo);
|
||||
|
||||
SDL_GPUGraphicsPipeline *(*CreateGraphicsPipeline)(
|
||||
SDL_GPURenderer *driverData,
|
||||
const SDL_GPUGraphicsPipelineCreateInfo *pipelineCreateInfo);
|
||||
const SDL_GPUGraphicsPipelineCreateInfo *createinfo);
|
||||
|
||||
SDL_GPUSampler *(*CreateSampler)(
|
||||
SDL_GPURenderer *driverData,
|
||||
const SDL_GPUSamplerCreateInfo *samplerCreateInfo);
|
||||
const SDL_GPUSamplerCreateInfo *createinfo);
|
||||
|
||||
SDL_GPUShader *(*CreateShader)(
|
||||
SDL_GPURenderer *driverData,
|
||||
const SDL_GPUShaderCreateInfo *shaderCreateInfo);
|
||||
const SDL_GPUShaderCreateInfo *createinfo);
|
||||
|
||||
SDL_GPUTexture *(*CreateTexture)(
|
||||
SDL_GPURenderer *driverData,
|
||||
const SDL_GPUTextureCreateInfo *textureCreateInfo);
|
||||
const SDL_GPUTextureCreateInfo *createinfo);
|
||||
|
||||
SDL_GPUBuffer *(*CreateBuffer)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_GPUBufferUsageFlags usageFlags,
|
||||
Uint32 sizeInBytes);
|
||||
Uint32 size);
|
||||
|
||||
SDL_GPUTransferBuffer *(*CreateTransferBuffer)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_GPUTransferBufferUsage usage,
|
||||
Uint32 sizeInBytes);
|
||||
Uint32 size);
|
||||
|
||||
// Debug Naming
|
||||
|
||||
@@ -382,9 +382,9 @@ struct SDL_GPUDevice
|
||||
|
||||
void (*BeginRenderPass)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
const SDL_GPUColorAttachmentInfo *colorAttachmentInfos,
|
||||
Uint32 colorAttachmentCount,
|
||||
const SDL_GPUDepthStencilAttachmentInfo *depthStencilAttachmentInfo);
|
||||
const SDL_GPUColorTargetInfo *colorTargetInfos,
|
||||
Uint32 numColorTargets,
|
||||
const SDL_GPUDepthStencilTargetInfo *depthStencilTargetInfo);
|
||||
|
||||
void (*BindGraphicsPipeline)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
@@ -409,90 +409,90 @@ struct SDL_GPUDevice
|
||||
void (*BindVertexBuffers)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 firstBinding,
|
||||
const SDL_GPUBufferBinding *pBindings,
|
||||
Uint32 bindingCount);
|
||||
const SDL_GPUBufferBinding *bindings,
|
||||
Uint32 numBindings);
|
||||
|
||||
void (*BindIndexBuffer)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
const SDL_GPUBufferBinding *pBinding,
|
||||
const SDL_GPUBufferBinding *binding,
|
||||
SDL_GPUIndexElementSize indexElementSize);
|
||||
|
||||
void (*BindVertexSamplers)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 firstSlot,
|
||||
const SDL_GPUTextureSamplerBinding *textureSamplerBindings,
|
||||
Uint32 bindingCount);
|
||||
Uint32 numBindings);
|
||||
|
||||
void (*BindVertexStorageTextures)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 firstSlot,
|
||||
SDL_GPUTexture *const *storageTextures,
|
||||
Uint32 bindingCount);
|
||||
Uint32 numBindings);
|
||||
|
||||
void (*BindVertexStorageBuffers)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 firstSlot,
|
||||
SDL_GPUBuffer *const *storageBuffers,
|
||||
Uint32 bindingCount);
|
||||
Uint32 numBindings);
|
||||
|
||||
void (*BindFragmentSamplers)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 firstSlot,
|
||||
const SDL_GPUTextureSamplerBinding *textureSamplerBindings,
|
||||
Uint32 bindingCount);
|
||||
Uint32 numBindings);
|
||||
|
||||
void (*BindFragmentStorageTextures)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 firstSlot,
|
||||
SDL_GPUTexture *const *storageTextures,
|
||||
Uint32 bindingCount);
|
||||
Uint32 numBindings);
|
||||
|
||||
void (*BindFragmentStorageBuffers)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 firstSlot,
|
||||
SDL_GPUBuffer *const *storageBuffers,
|
||||
Uint32 bindingCount);
|
||||
Uint32 numBindings);
|
||||
|
||||
void (*PushVertexUniformData)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 slotIndex,
|
||||
const void *data,
|
||||
Uint32 dataLengthInBytes);
|
||||
Uint32 length);
|
||||
|
||||
void (*PushFragmentUniformData)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 slotIndex,
|
||||
const void *data,
|
||||
Uint32 dataLengthInBytes);
|
||||
Uint32 length);
|
||||
|
||||
void (*DrawIndexedPrimitives)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 indexCount,
|
||||
Uint32 instanceCount,
|
||||
Uint32 numIndices,
|
||||
Uint32 numInstances,
|
||||
Uint32 firstIndex,
|
||||
Sint32 vertexOffset,
|
||||
Uint32 firstInstance);
|
||||
|
||||
void (*DrawPrimitives)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 vertexCount,
|
||||
Uint32 instanceCount,
|
||||
Uint32 numVertices,
|
||||
Uint32 numInstances,
|
||||
Uint32 firstVertex,
|
||||
Uint32 firstInstance);
|
||||
|
||||
void (*DrawPrimitivesIndirect)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
SDL_GPUBuffer *buffer,
|
||||
Uint32 offsetInBytes,
|
||||
Uint32 offset,
|
||||
Uint32 drawCount,
|
||||
Uint32 stride);
|
||||
Uint32 pitch);
|
||||
|
||||
void (*DrawIndexedPrimitivesIndirect)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
SDL_GPUBuffer *buffer,
|
||||
Uint32 offsetInBytes,
|
||||
Uint32 offset,
|
||||
Uint32 drawCount,
|
||||
Uint32 stride);
|
||||
Uint32 pitch);
|
||||
|
||||
void (*EndRenderPass)(
|
||||
SDL_GPUCommandBuffer *commandBuffer);
|
||||
@@ -502,9 +502,9 @@ struct SDL_GPUDevice
|
||||
void (*BeginComputePass)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
const SDL_GPUStorageTextureWriteOnlyBinding *storageTextureBindings,
|
||||
Uint32 storageTextureBindingCount,
|
||||
Uint32 numStorageTextureBindings,
|
||||
const SDL_GPUStorageBufferWriteOnlyBinding *storageBufferBindings,
|
||||
Uint32 storageBufferBindingCount);
|
||||
Uint32 numStorageBufferBindings);
|
||||
|
||||
void (*BindComputePipeline)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
@@ -514,30 +514,30 @@ struct SDL_GPUDevice
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 firstSlot,
|
||||
SDL_GPUTexture *const *storageTextures,
|
||||
Uint32 bindingCount);
|
||||
Uint32 numBindings);
|
||||
|
||||
void (*BindComputeStorageBuffers)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 firstSlot,
|
||||
SDL_GPUBuffer *const *storageBuffers,
|
||||
Uint32 bindingCount);
|
||||
Uint32 numBindings);
|
||||
|
||||
void (*PushComputeUniformData)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 slotIndex,
|
||||
const void *data,
|
||||
Uint32 dataLengthInBytes);
|
||||
Uint32 length);
|
||||
|
||||
void (*DispatchCompute)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 groupCountX,
|
||||
Uint32 groupCountY,
|
||||
Uint32 groupCountZ);
|
||||
Uint32 groupcountX,
|
||||
Uint32 groupcountY,
|
||||
Uint32 groupcountZ);
|
||||
|
||||
void (*DispatchComputeIndirect)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
SDL_GPUBuffer *buffer,
|
||||
Uint32 offsetInBytes);
|
||||
Uint32 offset);
|
||||
|
||||
void (*EndComputePass)(
|
||||
SDL_GPUCommandBuffer *commandBuffer);
|
||||
@@ -608,7 +608,7 @@ struct SDL_GPUDevice
|
||||
const SDL_GPUBlitRegion *source,
|
||||
const SDL_GPUBlitRegion *destination,
|
||||
SDL_FlipMode flipMode,
|
||||
SDL_GPUFilter filterMode,
|
||||
SDL_GPUFilter filter,
|
||||
bool cycle);
|
||||
|
||||
// Submission/Presentation
|
||||
@@ -647,8 +647,8 @@ struct SDL_GPUDevice
|
||||
SDL_GPUTexture *(*AcquireSwapchainTexture)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
SDL_Window *window,
|
||||
Uint32 *pWidth,
|
||||
Uint32 *pHeight);
|
||||
Uint32 *w,
|
||||
Uint32 *h);
|
||||
|
||||
void (*Submit)(
|
||||
SDL_GPUCommandBuffer *commandBuffer);
|
||||
@@ -662,8 +662,8 @@ struct SDL_GPUDevice
|
||||
void (*WaitForFences)(
|
||||
SDL_GPURenderer *driverData,
|
||||
bool waitAll,
|
||||
SDL_GPUFence *const *pFences,
|
||||
Uint32 fenceCount);
|
||||
SDL_GPUFence *const *fences,
|
||||
Uint32 numFences);
|
||||
|
||||
bool (*QueryFence)(
|
||||
SDL_GPURenderer *driverData,
|
||||
@@ -693,8 +693,8 @@ struct SDL_GPUDevice
|
||||
SDL_GPUDriver backend;
|
||||
|
||||
// Store this for SDL_gpu.c's debug layer
|
||||
bool debugMode;
|
||||
SDL_GPUShaderFormat shaderFormats;
|
||||
bool debug_mode;
|
||||
SDL_GPUShaderFormat shader_formats;
|
||||
};
|
||||
|
||||
#define ASSIGN_DRIVER_FUNC(func, name) \
|
||||
@@ -780,11 +780,11 @@ struct SDL_GPUDevice
|
||||
|
||||
typedef struct SDL_GPUBootstrap
|
||||
{
|
||||
const char *Name;
|
||||
const char *name;
|
||||
const SDL_GPUDriver backendflag;
|
||||
const SDL_GPUShaderFormat shaderFormats;
|
||||
const SDL_GPUShaderFormat shader_formats;
|
||||
bool (*PrepareDriver)(SDL_VideoDevice *_this);
|
||||
SDL_GPUDevice *(*CreateDevice)(bool debugMode, bool preferLowPower, SDL_PropertiesID props);
|
||||
SDL_GPUDevice *(*CreateDevice)(bool debug_mode, bool prefer_low_power, SDL_PropertiesID props);
|
||||
} SDL_GPUBootstrap;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
+362
-361
File diff suppressed because it is too large.
Load diff
+465
-465
File diff suppressed because it is too large.
Load diff
+343
-343
File diff suppressed because it is too large.
Load diff
+474
-474
File diff suppressed because it is too large.
Load diff
@@ -97,34 +97,34 @@ void GPU_DestroyPipelineCache(GPU_PipelineCache *cache)
|
||||
|
||||
static SDL_GPUGraphicsPipeline *MakePipeline(SDL_GPUDevice *device, GPU_Shaders *shaders, const GPU_PipelineParameters *params)
|
||||
{
|
||||
SDL_GPUColorAttachmentDescription ad;
|
||||
SDL_GPUColorTargetDescription ad;
|
||||
SDL_zero(ad);
|
||||
ad.format = params->attachment_format;
|
||||
|
||||
SDL_BlendMode blend = params->blend_mode;
|
||||
ad.blendState.blendEnable = blend != 0;
|
||||
ad.blendState.colorWriteMask = 0xF;
|
||||
ad.blendState.alphaBlendOp = GPU_ConvertBlendOperation(SDL_GetBlendModeAlphaOperation(blend));
|
||||
ad.blendState.dstAlphaBlendFactor = GPU_ConvertBlendFactor(SDL_GetBlendModeDstAlphaFactor(blend));
|
||||
ad.blendState.srcAlphaBlendFactor = GPU_ConvertBlendFactor(SDL_GetBlendModeSrcAlphaFactor(blend));
|
||||
ad.blendState.colorBlendOp = GPU_ConvertBlendOperation(SDL_GetBlendModeColorOperation(blend));
|
||||
ad.blendState.dstColorBlendFactor = GPU_ConvertBlendFactor(SDL_GetBlendModeDstColorFactor(blend));
|
||||
ad.blendState.srcColorBlendFactor = GPU_ConvertBlendFactor(SDL_GetBlendModeSrcColorFactor(blend));
|
||||
ad.blend_state.enable_blend = blend != 0;
|
||||
ad.blend_state.color_write_mask = 0xF;
|
||||
ad.blend_state.alpha_blend_op = GPU_ConvertBlendOperation(SDL_GetBlendModeAlphaOperation(blend));
|
||||
ad.blend_state.dst_alpha_blendfactor = GPU_ConvertBlendFactor(SDL_GetBlendModeDstAlphaFactor(blend));
|
||||
ad.blend_state.src_alpha_blendfactor = GPU_ConvertBlendFactor(SDL_GetBlendModeSrcAlphaFactor(blend));
|
||||
ad.blend_state.color_blend_op = GPU_ConvertBlendOperation(SDL_GetBlendModeColorOperation(blend));
|
||||
ad.blend_state.dst_color_blendfactor = GPU_ConvertBlendFactor(SDL_GetBlendModeDstColorFactor(blend));
|
||||
ad.blend_state.src_color_blendfactor = GPU_ConvertBlendFactor(SDL_GetBlendModeSrcColorFactor(blend));
|
||||
|
||||
SDL_GPUGraphicsPipelineCreateInfo pci;
|
||||
SDL_zero(pci);
|
||||
pci.attachmentInfo.hasDepthStencilAttachment = false;
|
||||
pci.attachmentInfo.colorAttachmentCount = 1;
|
||||
pci.attachmentInfo.colorAttachmentDescriptions = &ad;
|
||||
pci.vertexShader = GPU_GetVertexShader(shaders, params->vert_shader);
|
||||
pci.fragmentShader = GPU_GetFragmentShader(shaders, params->frag_shader);
|
||||
pci.multisampleState.sampleCount = SDL_GPU_SAMPLECOUNT_1;
|
||||
pci.multisampleState.sampleMask = 0xFFFF;
|
||||
pci.primitiveType = params->primitive_type;
|
||||
pci.target_info.has_depth_stencil_target = false;
|
||||
pci.target_info.num_color_targets = 1;
|
||||
pci.target_info.color_target_descriptions = &ad;
|
||||
pci.vertex_shader = GPU_GetVertexShader(shaders, params->vert_shader);
|
||||
pci.fragment_shader = GPU_GetFragmentShader(shaders, params->frag_shader);
|
||||
pci.multisample_state.sample_count = SDL_GPU_SAMPLECOUNT_1;
|
||||
pci.multisample_state.sample_mask = 0xFFFF;
|
||||
pci.primitive_type = params->primitive_type;
|
||||
|
||||
pci.rasterizerState.cullMode = SDL_GPU_CULLMODE_NONE;
|
||||
pci.rasterizerState.fillMode = SDL_GPU_FILLMODE_FILL;
|
||||
pci.rasterizerState.frontFace = SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE;
|
||||
pci.rasterizer_state.cull_mode = SDL_GPU_CULLMODE_NONE;
|
||||
pci.rasterizer_state.fill_mode = SDL_GPU_FILLMODE_FILL;
|
||||
pci.rasterizer_state.front_face = SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE;
|
||||
|
||||
SDL_GPUVertexBinding bind;
|
||||
SDL_zero(bind);
|
||||
@@ -150,16 +150,16 @@ static SDL_GPUGraphicsPipeline *MakePipeline(SDL_GPUDevice *device, GPU_Shaders
|
||||
// Position
|
||||
attribs[num_attribs].location = num_attribs;
|
||||
attribs[num_attribs].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2;
|
||||
attribs[num_attribs].offset = bind.stride;
|
||||
bind.stride += 2 * sizeof(float);
|
||||
attribs[num_attribs].offset = bind.pitch;
|
||||
bind.pitch += 2 * sizeof(float);
|
||||
num_attribs++;
|
||||
|
||||
if (have_attr_color) {
|
||||
// Color
|
||||
attribs[num_attribs].location = num_attribs;
|
||||
attribs[num_attribs].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4;
|
||||
attribs[num_attribs].offset = bind.stride;
|
||||
bind.stride += 4 * sizeof(float);
|
||||
attribs[num_attribs].offset = bind.pitch;
|
||||
bind.pitch += 4 * sizeof(float);
|
||||
num_attribs++;
|
||||
}
|
||||
|
||||
@@ -167,15 +167,15 @@ static SDL_GPUGraphicsPipeline *MakePipeline(SDL_GPUDevice *device, GPU_Shaders
|
||||
// UVs
|
||||
attribs[num_attribs].location = num_attribs;
|
||||
attribs[num_attribs].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2;
|
||||
attribs[num_attribs].offset = bind.stride;
|
||||
bind.stride += 2 * sizeof(float);
|
||||
attribs[num_attribs].offset = bind.pitch;
|
||||
bind.pitch += 2 * sizeof(float);
|
||||
num_attribs++;
|
||||
}
|
||||
|
||||
pci.vertexInputState.vertexAttributeCount = num_attribs;
|
||||
pci.vertexInputState.vertexAttributes = attribs;
|
||||
pci.vertexInputState.vertexBindingCount = 1;
|
||||
pci.vertexInputState.vertexBindings = &bind;
|
||||
pci.vertex_input_state.num_vertex_attributes = num_attribs;
|
||||
pci.vertex_input_state.vertex_attributes = attribs;
|
||||
pci.vertex_input_state.num_vertex_bindings = 1;
|
||||
pci.vertex_input_state.vertex_bindings = &bind;
|
||||
|
||||
return SDL_CreateGPUGraphicsPipeline(device, &pci);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ typedef struct GPU_RenderData
|
||||
SDL_GPURenderPass *render_pass;
|
||||
SDL_Texture *render_target;
|
||||
SDL_GPUCommandBuffer *command_buffer;
|
||||
SDL_GPUColorAttachmentInfo color_attachment;
|
||||
SDL_GPUColorTargetInfo color_attachment;
|
||||
SDL_GPUViewport viewport;
|
||||
SDL_Rect scissor;
|
||||
SDL_FColor draw_color;
|
||||
@@ -219,12 +219,12 @@ static bool GPU_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_
|
||||
SDL_GPUTextureCreateInfo tci;
|
||||
SDL_zero(tci);
|
||||
tci.format = format;
|
||||
tci.layerCountOrDepth = 1;
|
||||
tci.levelCount = 1;
|
||||
tci.usageFlags = usage;
|
||||
tci.layer_count_or_depth = 1;
|
||||
tci.num_levels = 1;
|
||||
tci.usage = usage;
|
||||
tci.width = texture->w;
|
||||
tci.height = texture->h;
|
||||
tci.sampleCount = SDL_GPU_SAMPLECOUNT_1;
|
||||
tci.sample_count = SDL_GPU_SAMPLECOUNT_1;
|
||||
|
||||
data->format = format;
|
||||
data->texture = SDL_CreateGPUTexture(renderdata->device, &tci);
|
||||
@@ -258,7 +258,7 @@ static bool GPU_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
|
||||
SDL_GPUTransferBufferCreateInfo tbci;
|
||||
SDL_zero(tbci);
|
||||
tbci.sizeInBytes = (Uint32)data_size;
|
||||
tbci.size = (Uint32)data_size;
|
||||
tbci.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD;
|
||||
|
||||
SDL_GPUTransferBuffer *tbuf = SDL_CreateGPUTransferBuffer(renderdata->device, &tbci);
|
||||
@@ -273,7 +273,7 @@ static bool GPU_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
memcpy(output, pixels, data_size);
|
||||
} else {
|
||||
// FIXME is negative pitch supposed to work?
|
||||
// If not, maybe use SDL_GPUTextureTransferInfo::imagePitch instead of this
|
||||
// If not, maybe use SDL_GPUTextureTransferInfo::pixels_per_row instead of this
|
||||
const Uint8 *input = pixels;
|
||||
|
||||
for (int i = 0; i < rect->h; ++i) {
|
||||
@@ -290,9 +290,9 @@ static bool GPU_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
|
||||
SDL_GPUTextureTransferInfo tex_src;
|
||||
SDL_zero(tex_src);
|
||||
tex_src.transferBuffer = tbuf;
|
||||
tex_src.imageHeight = rect->h;
|
||||
tex_src.imagePitch = rect->w;
|
||||
tex_src.transfer_buffer = tbuf;
|
||||
tex_src.rows_per_layer = rect->h;
|
||||
tex_src.pixels_per_row = rect->w;
|
||||
|
||||
SDL_GPUTextureRegion tex_dst;
|
||||
SDL_zero(tex_dst);
|
||||
@@ -467,7 +467,7 @@ static SDL_GPURenderPass *RestartRenderPass(GPU_RenderData *data)
|
||||
// This is busted. We should be able to know which load op to use.
|
||||
// LOAD is incorrect behavior most of the time, unless we had to break a render pass.
|
||||
// -cosmonaut
|
||||
data->state.color_attachment.loadOp = SDL_GPU_LOADOP_LOAD;
|
||||
data->state.color_attachment.load_op = SDL_GPU_LOADOP_LOAD;
|
||||
data->state.scissor_was_enabled = false;
|
||||
|
||||
return data->state.render_pass;
|
||||
@@ -524,7 +524,7 @@ static void Draw(
|
||||
Uint32 offset,
|
||||
SDL_GPUPrimitiveType prim)
|
||||
{
|
||||
if (!data->state.render_pass || data->state.color_attachment.loadOp == SDL_GPU_LOADOP_CLEAR) {
|
||||
if (!data->state.render_pass || data->state.color_attachment.load_op == SDL_GPU_LOADOP_CLEAR) {
|
||||
RestartRenderPass(data);
|
||||
}
|
||||
|
||||
@@ -607,8 +607,8 @@ static bool InitVertexBuffer(GPU_RenderData *data, Uint32 size)
|
||||
{
|
||||
SDL_GPUBufferCreateInfo bci;
|
||||
SDL_zero(bci);
|
||||
bci.sizeInBytes = size;
|
||||
bci.usageFlags = SDL_GPU_BUFFERUSAGE_VERTEX;
|
||||
bci.size = size;
|
||||
bci.usage = SDL_GPU_BUFFERUSAGE_VERTEX;
|
||||
|
||||
data->vertices.buffer = SDL_CreateGPUBuffer(data->device, &bci);
|
||||
|
||||
@@ -618,7 +618,7 @@ static bool InitVertexBuffer(GPU_RenderData *data, Uint32 size)
|
||||
|
||||
SDL_GPUTransferBufferCreateInfo tbci;
|
||||
SDL_zero(tbci);
|
||||
tbci.sizeInBytes = size;
|
||||
tbci.size = size;
|
||||
tbci.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD;
|
||||
|
||||
data->vertices.transfer_buf = SDL_CreateGPUTransferBuffer(data->device, &tbci);
|
||||
@@ -655,7 +655,7 @@ static bool UploadVertices(GPU_RenderData *data, void *vertices, size_t vertsize
|
||||
|
||||
SDL_GPUTransferBufferLocation src;
|
||||
SDL_zero(src);
|
||||
src.transferBuffer = data->vertices.transfer_buf;
|
||||
src.transfer_buffer = data->vertices.transfer_buf;
|
||||
|
||||
SDL_GPUBufferRegion dst;
|
||||
SDL_zero(dst);
|
||||
@@ -685,7 +685,7 @@ static bool GPU_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
return false;
|
||||
}
|
||||
|
||||
data->state.color_attachment.loadOp = SDL_GPU_LOADOP_LOAD;
|
||||
data->state.color_attachment.load_op = SDL_GPU_LOADOP_LOAD;
|
||||
|
||||
if (renderer->target) {
|
||||
GPU_TextureData *tdata = renderer->target->internal;
|
||||
@@ -729,8 +729,8 @@ static bool GPU_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
|
||||
case SDL_RENDERCMD_CLEAR:
|
||||
{
|
||||
data->state.color_attachment.clearColor = GetDrawCmdColor(renderer, cmd);
|
||||
data->state.color_attachment.loadOp = SDL_GPU_LOADOP_CLEAR;
|
||||
data->state.color_attachment.clear_color = GetDrawCmdColor(renderer, cmd);
|
||||
data->state.color_attachment.load_op = SDL_GPU_LOADOP_CLEAR;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -823,7 +823,7 @@ static bool GPU_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
cmd = cmd->next;
|
||||
}
|
||||
|
||||
if (data->state.color_attachment.loadOp == SDL_GPU_LOADOP_CLEAR) {
|
||||
if (data->state.color_attachment.load_op == SDL_GPU_LOADOP_CLEAR) {
|
||||
RestartRenderPass(data);
|
||||
}
|
||||
|
||||
@@ -873,7 +873,7 @@ static SDL_Surface *GPU_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect
|
||||
|
||||
SDL_GPUTransferBufferCreateInfo tbci;
|
||||
SDL_zero(tbci);
|
||||
tbci.sizeInBytes = (Uint32)image_size;
|
||||
tbci.size = (Uint32)image_size;
|
||||
tbci.usage = SDL_GPU_TRANSFERBUFFERUSAGE_DOWNLOAD;
|
||||
|
||||
SDL_GPUTransferBuffer *tbuf = SDL_CreateGPUTransferBuffer(data->device, &tbci);
|
||||
@@ -895,9 +895,9 @@ static SDL_Surface *GPU_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect
|
||||
|
||||
SDL_GPUTextureTransferInfo dst;
|
||||
SDL_zero(dst);
|
||||
dst.transferBuffer = tbuf;
|
||||
dst.imageHeight = rect->h;
|
||||
dst.imagePitch = rect->w;
|
||||
dst.transfer_buffer = tbuf;
|
||||
dst.rows_per_layer = rect->h;
|
||||
dst.pixels_per_row = rect->w;
|
||||
|
||||
SDL_DownloadFromGPUTexture(pass, &src, &dst);
|
||||
SDL_EndGPUCopyPass(pass);
|
||||
@@ -935,10 +935,10 @@ static bool CreateBackbuffer(GPU_RenderData *data, Uint32 w, Uint32 h, SDL_GPUTe
|
||||
tci.width = w;
|
||||
tci.height = h;
|
||||
tci.format = fmt;
|
||||
tci.layerCountOrDepth = 1;
|
||||
tci.levelCount = 1;
|
||||
tci.sampleCount = SDL_GPU_SAMPLECOUNT_1;
|
||||
tci.usageFlags = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER;
|
||||
tci.layer_count_or_depth = 1;
|
||||
tci.num_levels = 1;
|
||||
tci.sample_count = SDL_GPU_SAMPLECOUNT_1;
|
||||
tci.usage = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER;
|
||||
|
||||
data->backbuffer.texture = SDL_CreateGPUTexture(data->device, &tci);
|
||||
data->backbuffer.width = w;
|
||||
@@ -1167,11 +1167,11 @@ static bool InitSamplers(GPU_RenderData *data)
|
||||
for (Uint32 i = 0; i < SDL_arraysize(configs); ++i) {
|
||||
SDL_GPUSamplerCreateInfo sci;
|
||||
SDL_zero(sci);
|
||||
sci.maxAnisotropy = configs[i].gpu.anisotropy;
|
||||
sci.anisotropyEnable = configs[i].gpu.anisotropy > 0;
|
||||
sci.addressModeU = sci.addressModeV = sci.addressModeW = configs[i].gpu.address_mode;
|
||||
sci.minFilter = sci.magFilter = configs[i].gpu.filter;
|
||||
sci.mipmapMode = configs[i].gpu.mipmap_mode;
|
||||
sci.max_anisotropy = configs[i].gpu.anisotropy;
|
||||
sci.enable_anisotropy = configs[i].gpu.anisotropy > 0;
|
||||
sci.address_mode_u = sci.address_mode_v = sci.address_mode_w = configs[i].gpu.address_mode;
|
||||
sci.min_filter = sci.mag_filter = configs[i].gpu.filter;
|
||||
sci.mipmap_mode = configs[i].gpu.mipmap_mode;
|
||||
|
||||
SDL_GPUSampler *sampler = SDL_CreateGPUSampler(data->device, &sci);
|
||||
|
||||
@@ -1286,8 +1286,8 @@ static bool GPU_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_P
|
||||
data->state.draw_color.g = 1.0f;
|
||||
data->state.draw_color.b = 1.0f;
|
||||
data->state.draw_color.a = 1.0f;
|
||||
data->state.viewport.minDepth = 0;
|
||||
data->state.viewport.maxDepth = 1;
|
||||
data->state.viewport.min_depth = 0;
|
||||
data->state.viewport.max_depth = 1;
|
||||
data->state.command_buffer = SDL_AcquireGPUCommandBuffer(data->device);
|
||||
|
||||
int w, h;
|
||||
|
||||
@@ -167,12 +167,12 @@ static SDL_GPUShader *CompileShader(const GPU_ShaderSources *sources, SDL_GPUDev
|
||||
|
||||
SDL_GPUShaderCreateInfo sci = { 0 };
|
||||
sci.code = sms->code;
|
||||
sci.codeSize = sms->code_len;
|
||||
sci.code_size = sms->code_len;
|
||||
sci.format = sms->format;
|
||||
// FIXME not sure if this is correct
|
||||
sci.entryPointName = driver == SDL_GPU_DRIVER_METAL ? "main0" : "main";
|
||||
sci.samplerCount = sources->num_samplers;
|
||||
sci.uniformBufferCount = sources->num_uniform_buffers;
|
||||
sci.entrypoint = driver == SDL_GPU_DRIVER_METAL ? "main0" : "main";
|
||||
sci.num_samplers = sources->num_samplers;
|
||||
sci.num_uniform_buffers = sources->num_uniform_buffers;
|
||||
sci.stage = stage;
|
||||
|
||||
return SDL_CreateGPUShader(device, &sci);
|
||||
|
||||
Reference in new issue
Block a user