mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-21 22:32:31 +08:00
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:
+412
-421
File diff suppressed because it is too large
Load Diff
@@ -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);
|
||||
|
||||
+10
-11
@@ -89,17 +89,17 @@ SDL_AppResult SDL_AppIterate(void *appstate)
|
||||
if (swapchainTexture != NULL) {
|
||||
const double currentTime = (double)SDL_GetPerformanceCounter() / SDL_GetPerformanceFrequency();
|
||||
SDL_GPURenderPass *renderPass;
|
||||
SDL_GPUColorAttachmentInfo colorAttachmentInfo;
|
||||
SDL_zero(colorAttachmentInfo);
|
||||
colorAttachmentInfo.texture = swapchainTexture;
|
||||
colorAttachmentInfo.clearColor.r = (float)(0.5 + 0.5 * SDL_sin(currentTime));
|
||||
colorAttachmentInfo.clearColor.g = (float)(0.5 + 0.5 * SDL_sin(currentTime + SDL_PI_D * 2 / 3));
|
||||
colorAttachmentInfo.clearColor.b = (float)(0.5 + 0.5 * SDL_sin(currentTime + SDL_PI_D * 4 / 3));;
|
||||
colorAttachmentInfo.clearColor.a = 1.0f;
|
||||
colorAttachmentInfo.loadOp = SDL_GPU_LOADOP_CLEAR;
|
||||
colorAttachmentInfo.storeOp = SDL_GPU_STOREOP_STORE;
|
||||
SDL_GPUColorTargetInfo color_target_info;
|
||||
SDL_zero(color_target_info);
|
||||
color_target_info.texture = swapchainTexture;
|
||||
color_target_info.clear_color.r = (float)(0.5 + 0.5 * SDL_sin(currentTime));
|
||||
color_target_info.clear_color.g = (float)(0.5 + 0.5 * SDL_sin(currentTime + SDL_PI_D * 2 / 3));
|
||||
color_target_info.clear_color.b = (float)(0.5 + 0.5 * SDL_sin(currentTime + SDL_PI_D * 4 / 3));;
|
||||
color_target_info.clear_color.a = 1.0f;
|
||||
color_target_info.load_op = SDL_GPU_LOADOP_CLEAR;
|
||||
color_target_info.store_op = SDL_GPU_STOREOP_STORE;
|
||||
|
||||
renderPass = SDL_BeginGPURenderPass(cmdbuf, &colorAttachmentInfo, 1, NULL);
|
||||
renderPass = SDL_BeginGPURenderPass(cmdbuf, &color_target_info, 1, NULL);
|
||||
SDL_EndGPURenderPass(renderPass);
|
||||
}
|
||||
|
||||
@@ -122,4 +122,3 @@ void SDL_AppQuit(void *appstate)
|
||||
SDL_DestroyGPUDevice(gpu_device);
|
||||
SDLTest_CommonQuit(state);
|
||||
}
|
||||
|
||||
|
||||
@@ -256,10 +256,10 @@ CreateDepthTexture(Uint32 drawablew, Uint32 drawableh)
|
||||
depthtex_createinfo.format = SDL_GPU_TEXTUREFORMAT_D16_UNORM;
|
||||
depthtex_createinfo.width = drawablew;
|
||||
depthtex_createinfo.height = drawableh;
|
||||
depthtex_createinfo.layerCountOrDepth = 1;
|
||||
depthtex_createinfo.levelCount = 1;
|
||||
depthtex_createinfo.sampleCount = render_state.sample_count;
|
||||
depthtex_createinfo.usageFlags = SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET;
|
||||
depthtex_createinfo.layer_count_or_depth = 1;
|
||||
depthtex_createinfo.num_levels = 1;
|
||||
depthtex_createinfo.sample_count = render_state.sample_count;
|
||||
depthtex_createinfo.usage = SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET;
|
||||
depthtex_createinfo.props = 0;
|
||||
|
||||
result = SDL_CreateGPUTexture(gpu_device, &depthtex_createinfo);
|
||||
@@ -282,10 +282,10 @@ CreateMSAATexture(Uint32 drawablew, Uint32 drawableh)
|
||||
msaatex_createinfo.format = SDL_GetGPUSwapchainTextureFormat(gpu_device, state->windows[0]);
|
||||
msaatex_createinfo.width = drawablew;
|
||||
msaatex_createinfo.height = drawableh;
|
||||
msaatex_createinfo.layerCountOrDepth = 1;
|
||||
msaatex_createinfo.levelCount = 1;
|
||||
msaatex_createinfo.sampleCount = render_state.sample_count;
|
||||
msaatex_createinfo.usageFlags = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER;
|
||||
msaatex_createinfo.layer_count_or_depth = 1;
|
||||
msaatex_createinfo.num_levels = 1;
|
||||
msaatex_createinfo.sample_count = render_state.sample_count;
|
||||
msaatex_createinfo.usage = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER;
|
||||
msaatex_createinfo.props = 0;
|
||||
|
||||
result = SDL_CreateGPUTexture(gpu_device, &msaatex_createinfo);
|
||||
@@ -299,8 +299,8 @@ Render(SDL_Window *window, const int windownum)
|
||||
{
|
||||
WindowState *winstate = &window_states[windownum];
|
||||
SDL_GPUTexture *swapchain;
|
||||
SDL_GPUColorAttachmentInfo color_attachment;
|
||||
SDL_GPUDepthStencilAttachmentInfo depth_attachment;
|
||||
SDL_GPUColorTargetInfo color_target;
|
||||
SDL_GPUDepthStencilTargetInfo depth_target;
|
||||
float matrix_rotate[16], matrix_modelview[16], matrix_perspective[16], matrix_final[16];
|
||||
Uint32 drawablew, drawableh;
|
||||
SDL_GPUCommandBuffer *cmd;
|
||||
@@ -363,18 +363,18 @@ Render(SDL_Window *window, const int windownum)
|
||||
|
||||
/* Set up the pass */
|
||||
|
||||
SDL_zero(color_attachment);
|
||||
color_attachment.clearColor.a = 1.0f;
|
||||
color_attachment.loadOp = SDL_GPU_LOADOP_CLEAR;
|
||||
color_attachment.storeOp = SDL_GPU_STOREOP_STORE;
|
||||
color_attachment.texture = winstate->tex_msaa ? winstate->tex_msaa : swapchain;
|
||||
SDL_zero(color_target);
|
||||
color_target.clear_color.a = 1.0f;
|
||||
color_target.load_op = SDL_GPU_LOADOP_CLEAR;
|
||||
color_target.store_op = SDL_GPU_STOREOP_STORE;
|
||||
color_target.texture = winstate->tex_msaa ? winstate->tex_msaa : swapchain;
|
||||
|
||||
SDL_zero(depth_attachment);
|
||||
depth_attachment.depthStencilClearValue.depth = 1.0f;
|
||||
depth_attachment.loadOp = SDL_GPU_LOADOP_CLEAR;
|
||||
depth_attachment.storeOp = SDL_GPU_STOREOP_DONT_CARE;
|
||||
depth_attachment.texture = winstate->tex_depth;
|
||||
depth_attachment.cycle = SDL_TRUE;
|
||||
SDL_zero(depth_target);
|
||||
depth_target.clear_value.depth = 1.0f;
|
||||
depth_target.load_op = SDL_GPU_LOADOP_CLEAR;
|
||||
depth_target.store_op = SDL_GPU_STOREOP_DONT_CARE;
|
||||
depth_target.texture = winstate->tex_depth;
|
||||
depth_target.cycle = SDL_TRUE;
|
||||
|
||||
/* Set up the bindings */
|
||||
|
||||
@@ -385,7 +385,7 @@ Render(SDL_Window *window, const int windownum)
|
||||
|
||||
SDL_PushGPUVertexUniformData(cmd, 0, matrix_final, sizeof(matrix_final));
|
||||
|
||||
pass = SDL_BeginGPURenderPass(cmd, &color_attachment, 1, &depth_attachment);
|
||||
pass = SDL_BeginGPURenderPass(cmd, &color_target, 1, &depth_target);
|
||||
SDL_BindGPUGraphicsPipeline(pass, render_state.pipeline);
|
||||
SDL_BindGPUVertexBuffers(pass, 0, &vertex_binding, 1);
|
||||
SDL_DrawGPUPrimitives(pass, 36, 1, 0, 0);
|
||||
@@ -414,33 +414,33 @@ static SDL_GPUShader*
|
||||
load_shader(SDL_bool is_vertex)
|
||||
{
|
||||
SDL_GPUShaderCreateInfo createinfo;
|
||||
createinfo.samplerCount = 0;
|
||||
createinfo.storageBufferCount = 0;
|
||||
createinfo.storageTextureCount = 0;
|
||||
createinfo.uniformBufferCount = is_vertex ? 1 : 0;
|
||||
createinfo.num_samplers = 0;
|
||||
createinfo.num_storage_buffers = 0;
|
||||
createinfo.num_storage_textures = 0;
|
||||
createinfo.num_uniform_buffers = is_vertex ? 1 : 0;
|
||||
createinfo.props = 0;
|
||||
|
||||
SDL_GPUDriver backend = SDL_GetGPUDriver(gpu_device);
|
||||
if (backend == SDL_GPU_DRIVER_D3D11) {
|
||||
createinfo.format = SDL_GPU_SHADERFORMAT_DXBC;
|
||||
createinfo.code = is_vertex ? D3D11_CubeVert : D3D11_CubeFrag;
|
||||
createinfo.codeSize = is_vertex ? SDL_arraysize(D3D11_CubeVert) : SDL_arraysize(D3D11_CubeFrag);
|
||||
createinfo.entryPointName = is_vertex ? "VSMain" : "PSMain";
|
||||
createinfo.code_size = is_vertex ? SDL_arraysize(D3D11_CubeVert) : SDL_arraysize(D3D11_CubeFrag);
|
||||
createinfo.entrypoint = is_vertex ? "VSMain" : "PSMain";
|
||||
} else if (backend == SDL_GPU_DRIVER_D3D12) {
|
||||
createinfo.format = SDL_GPU_SHADERFORMAT_DXIL;
|
||||
createinfo.code = is_vertex ? D3D12_CubeVert : D3D12_CubeFrag;
|
||||
createinfo.codeSize = is_vertex ? SDL_arraysize(D3D12_CubeVert) : SDL_arraysize(D3D12_CubeFrag);
|
||||
createinfo.entryPointName = is_vertex ? "VSMain" : "PSMain";
|
||||
createinfo.code_size = is_vertex ? SDL_arraysize(D3D12_CubeVert) : SDL_arraysize(D3D12_CubeFrag);
|
||||
createinfo.entrypoint = is_vertex ? "VSMain" : "PSMain";
|
||||
} else if (backend == SDL_GPU_DRIVER_METAL) {
|
||||
createinfo.format = SDL_GPU_SHADERFORMAT_METALLIB;
|
||||
createinfo.code = is_vertex ? cube_vert_metallib : cube_frag_metallib;
|
||||
createinfo.codeSize = is_vertex ? cube_vert_metallib_len : cube_frag_metallib_len;
|
||||
createinfo.entryPointName = is_vertex ? "vs_main" : "fs_main";
|
||||
createinfo.code_size = is_vertex ? cube_vert_metallib_len : cube_frag_metallib_len;
|
||||
createinfo.entrypoint = is_vertex ? "vs_main" : "fs_main";
|
||||
} else {
|
||||
createinfo.format = SDL_GPU_SHADERFORMAT_SPIRV;
|
||||
createinfo.code = is_vertex ? cube_vert_spv : cube_frag_spv;
|
||||
createinfo.codeSize = is_vertex ? cube_vert_spv_len : cube_frag_spv_len;
|
||||
createinfo.entryPointName = "main";
|
||||
createinfo.code_size = is_vertex ? cube_vert_spv_len : cube_frag_spv_len;
|
||||
createinfo.entrypoint = "main";
|
||||
}
|
||||
|
||||
createinfo.stage = is_vertex ? SDL_GPU_SHADERSTAGE_VERTEX : SDL_GPU_SHADERSTAGE_FRAGMENT;
|
||||
@@ -459,7 +459,7 @@ init_render_state(int msaa)
|
||||
SDL_GPUBufferCreateInfo buffer_desc;
|
||||
SDL_GPUTransferBufferCreateInfo transfer_buffer_desc;
|
||||
SDL_GPUGraphicsPipelineCreateInfo pipelinedesc;
|
||||
SDL_GPUColorAttachmentDescription color_attachment_desc;
|
||||
SDL_GPUColorTargetDescription color_target_desc;
|
||||
Uint32 drawablew, drawableh;
|
||||
SDL_GPUVertexAttribute vertex_attributes[2];
|
||||
SDL_GPUVertexBinding vertex_binding;
|
||||
@@ -492,8 +492,8 @@ init_render_state(int msaa)
|
||||
|
||||
/* Create buffers */
|
||||
|
||||
buffer_desc.usageFlags = SDL_GPU_BUFFERUSAGE_VERTEX;
|
||||
buffer_desc.sizeInBytes = sizeof(vertex_data);
|
||||
buffer_desc.usage = SDL_GPU_BUFFERUSAGE_VERTEX;
|
||||
buffer_desc.size = sizeof(vertex_data);
|
||||
buffer_desc.props = 0;
|
||||
render_state.buf_vertex = SDL_CreateGPUBuffer(
|
||||
gpu_device,
|
||||
@@ -504,7 +504,7 @@ init_render_state(int msaa)
|
||||
SDL_SetGPUBufferName(gpu_device, render_state.buf_vertex, "космонавт");
|
||||
|
||||
transfer_buffer_desc.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD;
|
||||
transfer_buffer_desc.sizeInBytes = sizeof(vertex_data);
|
||||
transfer_buffer_desc.size = sizeof(vertex_data);
|
||||
transfer_buffer_desc.props = 0;
|
||||
buf_transfer = SDL_CreateGPUTransferBuffer(
|
||||
gpu_device,
|
||||
@@ -519,7 +519,7 @@ init_render_state(int msaa)
|
||||
|
||||
cmd = SDL_AcquireGPUCommandBuffer(gpu_device);
|
||||
copy_pass = SDL_BeginGPUCopyPass(cmd);
|
||||
buf_location.transferBuffer = buf_transfer;
|
||||
buf_location.transfer_buffer = buf_transfer;
|
||||
buf_location.offset = 0;
|
||||
dst_region.buffer = render_state.buf_vertex;
|
||||
dst_region.offset = 0;
|
||||
@@ -543,38 +543,38 @@ init_render_state(int msaa)
|
||||
|
||||
SDL_zero(pipelinedesc);
|
||||
|
||||
color_attachment_desc.format = SDL_GetGPUSwapchainTextureFormat(gpu_device, state->windows[0]);
|
||||
color_target_desc.format = SDL_GetGPUSwapchainTextureFormat(gpu_device, state->windows[0]);
|
||||
|
||||
color_attachment_desc.blendState.blendEnable = 0;
|
||||
color_attachment_desc.blendState.alphaBlendOp = SDL_GPU_BLENDOP_ADD;
|
||||
color_attachment_desc.blendState.colorBlendOp = SDL_GPU_BLENDOP_ADD;
|
||||
color_attachment_desc.blendState.colorWriteMask = 0xF;
|
||||
color_attachment_desc.blendState.srcAlphaBlendFactor = SDL_GPU_BLENDFACTOR_ONE;
|
||||
color_attachment_desc.blendState.dstAlphaBlendFactor = SDL_GPU_BLENDFACTOR_ZERO;
|
||||
color_attachment_desc.blendState.srcColorBlendFactor = SDL_GPU_BLENDFACTOR_ONE;
|
||||
color_attachment_desc.blendState.dstColorBlendFactor = SDL_GPU_BLENDFACTOR_ZERO;
|
||||
color_target_desc.blend_state.enable_blend = 0;
|
||||
color_target_desc.blend_state.alpha_blend_op = SDL_GPU_BLENDOP_ADD;
|
||||
color_target_desc.blend_state.color_blend_op = SDL_GPU_BLENDOP_ADD;
|
||||
color_target_desc.blend_state.color_write_mask = 0xF;
|
||||
color_target_desc.blend_state.src_alpha_blendfactor = SDL_GPU_BLENDFACTOR_ONE;
|
||||
color_target_desc.blend_state.dst_alpha_blendfactor = SDL_GPU_BLENDFACTOR_ZERO;
|
||||
color_target_desc.blend_state.src_color_blendfactor = SDL_GPU_BLENDFACTOR_ONE;
|
||||
color_target_desc.blend_state.dst_color_blendfactor = SDL_GPU_BLENDFACTOR_ZERO;
|
||||
|
||||
pipelinedesc.attachmentInfo.colorAttachmentCount = 1;
|
||||
pipelinedesc.attachmentInfo.colorAttachmentDescriptions = &color_attachment_desc;
|
||||
pipelinedesc.attachmentInfo.depthStencilFormat = SDL_GPU_TEXTUREFORMAT_D16_UNORM;
|
||||
pipelinedesc.attachmentInfo.hasDepthStencilAttachment = SDL_TRUE;
|
||||
pipelinedesc.target_info.num_color_targets = 1;
|
||||
pipelinedesc.target_info.color_target_descriptions = &color_target_desc;
|
||||
pipelinedesc.target_info.depth_stencil_format = SDL_GPU_TEXTUREFORMAT_D16_UNORM;
|
||||
pipelinedesc.target_info.has_depth_stencil_target = SDL_TRUE;
|
||||
|
||||
pipelinedesc.depthStencilState.depthTestEnable = 1;
|
||||
pipelinedesc.depthStencilState.depthWriteEnable = 1;
|
||||
pipelinedesc.depthStencilState.compareOp = SDL_GPU_COMPAREOP_LESS_OR_EQUAL;
|
||||
pipelinedesc.depth_stencil_state.enable_depth_test = 1;
|
||||
pipelinedesc.depth_stencil_state.enable_depth_write = 1;
|
||||
pipelinedesc.depth_stencil_state.compare_op = SDL_GPU_COMPAREOP_LESS_OR_EQUAL;
|
||||
|
||||
pipelinedesc.multisampleState.sampleCount = render_state.sample_count;
|
||||
pipelinedesc.multisampleState.sampleMask = 0xF;
|
||||
pipelinedesc.multisample_state.sample_count = render_state.sample_count;
|
||||
pipelinedesc.multisample_state.sample_mask = 0xF;
|
||||
|
||||
pipelinedesc.primitiveType = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST;
|
||||
pipelinedesc.primitive_type = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST;
|
||||
|
||||
pipelinedesc.vertexShader = vertex_shader;
|
||||
pipelinedesc.fragmentShader = fragment_shader;
|
||||
pipelinedesc.vertex_shader = vertex_shader;
|
||||
pipelinedesc.fragment_shader = fragment_shader;
|
||||
|
||||
vertex_binding.binding = 0;
|
||||
vertex_binding.inputRate = SDL_GPU_VERTEXINPUTRATE_VERTEX;
|
||||
vertex_binding.instanceStepRate = 0;
|
||||
vertex_binding.stride = sizeof(VertexData);
|
||||
vertex_binding.input_rate = SDL_GPU_VERTEXINPUTRATE_VERTEX;
|
||||
vertex_binding.instance_step_rate = 0;
|
||||
vertex_binding.pitch = sizeof(VertexData);
|
||||
|
||||
vertex_attributes[0].binding = 0;
|
||||
vertex_attributes[0].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3;
|
||||
@@ -586,10 +586,10 @@ init_render_state(int msaa)
|
||||
vertex_attributes[1].location = 1;
|
||||
vertex_attributes[1].offset = sizeof(float) * 3;
|
||||
|
||||
pipelinedesc.vertexInputState.vertexBindingCount = 1;
|
||||
pipelinedesc.vertexInputState.vertexBindings = &vertex_binding;
|
||||
pipelinedesc.vertexInputState.vertexAttributeCount = 2;
|
||||
pipelinedesc.vertexInputState.vertexAttributes = (SDL_GPUVertexAttribute*) &vertex_attributes;
|
||||
pipelinedesc.vertex_input_state.num_vertex_bindings = 1;
|
||||
pipelinedesc.vertex_input_state.vertex_bindings = &vertex_binding;
|
||||
pipelinedesc.vertex_input_state.num_vertex_attributes = 2;
|
||||
pipelinedesc.vertex_input_state.vertex_attributes = (SDL_GPUVertexAttribute*) &vertex_attributes;
|
||||
|
||||
pipelinedesc.props = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user