Skip to content

Commit

Permalink
Update for latest GPU ABI
Browse files Browse the repository at this point in the history
  • Loading branch information
flibitijibibo committed Aug 31, 2024
1 parent 162ed8b commit 9485200
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 67 deletions.
30 changes: 15 additions & 15 deletions mojoshader.h
Original file line number Diff line number Diff line change
Expand Up @@ -4106,16 +4106,16 @@ typedef struct MOJOSHADER_sdlVertexAttribute
} MOJOSHADER_sdlVertexAttribute;

#ifndef SDL_GPU_H
typedef struct SDL_GpuDevice SDL_GpuDevice;
typedef struct SDL_GpuShader SDL_GpuShader;
typedef struct SDL_GpuCommandBuffer SDL_GpuCommandBuffer;
typedef struct SDL_GPUDevice SDL_GPUDevice;
typedef struct SDL_GPUShader SDL_GPUShader;
typedef struct SDL_GPUCommandBuffer SDL_GPUCommandBuffer;
#endif /* SDL_GPU_H */

/*
* Call this function to get the 'formatFlags' parameter for
* SDL_CreateGpuDevice.
* SDL_CreateGPUDevice.
*
* Returns the SDL_GpuShaderFormatFlagBits for creating the SDL_GpuDevice.
* Returns the SDL_GPUShaderFormatFlagBits for creating the SDL_GPUDevice.
*/
DECLSPEC unsigned int MOJOSHADER_sdlGetShaderFormats(void);

Expand All @@ -4124,7 +4124,7 @@ DECLSPEC unsigned int MOJOSHADER_sdlGetShaderFormats(void);
*
* You do not need to call this if all you want is MOJOSHADER_parse().
*
* (device) refers to the SDL_GpuDevice.
* (device) refers to the SDL_GPUDevice.
*
* You can only have one MOJOSHADER_sdlContext per actual SDL_gpu context, or
* undefined behaviour will result.
Expand All @@ -4139,7 +4139,7 @@ DECLSPEC unsigned int MOJOSHADER_sdlGetShaderFormats(void);
*
* Returns a new context on success, NULL on error.
*/
DECLSPEC MOJOSHADER_sdlContext *MOJOSHADER_sdlCreateContext(SDL_GpuDevice *device,
DECLSPEC MOJOSHADER_sdlContext *MOJOSHADER_sdlCreateContext(SDL_GPUDevice *device,
MOJOSHADER_malloc m,
MOJOSHADER_free f,
void *malloc_d);
Expand Down Expand Up @@ -4168,7 +4168,7 @@ DECLSPEC const char *MOJOSHADER_sdlGetError(MOJOSHADER_sdlContext *ctx);
/*
* Deinitialize MojoShader's SDL_gpu shader management.
*
* You must call this once, while your SDL_GpuDevice is still valid. This should
* You must call this once, while your SDL_GPUDevice is still valid. This should
* be the last MOJOSHADER_sdl* function you call until you've prepared a context
* again.
*
Expand Down Expand Up @@ -4312,18 +4312,18 @@ DECLSPEC void MOJOSHADER_sdlUnmapUniformBufferMemory(MOJOSHADER_sdlContext *ctx)

/*
* Returns the minimum required size of the uniform buffer for this shader.
* You will need this to fill out the SDL_GpuGraphicsPipelineCreateInfo struct.
* You will need this to fill out the SDL_GPUGraphicsPipelineCreateInfo struct.
*/
DECLSPEC int MOJOSHADER_sdlGetUniformBufferSize(MOJOSHADER_sdlShaderData *shader);

/*
* Pushes the uniform buffer updates for the currently bound program.
*
* This function will record calls to SDL_GpuPush*ShaderUniforms into the
* This function will record calls to SDL_GPUPush*ShaderUniforms into the
* passed command buffer.
*/
DECLSPEC void MOJOSHADER_sdlUpdateUniformBuffers(MOJOSHADER_sdlContext *ctx,
SDL_GpuCommandBuffer *cb);
SDL_GPUCommandBuffer *cb);

/*
* Return the location of a vertex attribute for the given shader.
Expand All @@ -4332,18 +4332,18 @@ DECLSPEC void MOJOSHADER_sdlUpdateUniformBuffers(MOJOSHADER_sdlContext *ctx,
* be MOJOSHADER_USAGE_COLOR and 1.
*
* The return value is the index of the attribute to be used to create
* an SDL_GpuVertexAttribute, or -1 if the stream is not used.
* an SDL_GPUVertexAttribute, or -1 if the stream is not used.
*/
DECLSPEC int MOJOSHADER_sdlGetVertexAttribLocation(MOJOSHADER_sdlShaderData *vert,
MOJOSHADER_usage usage,
int index);

/*
* Get the SDL_GpuShaderModules from the currently bound shader program.
* Get the SDL_GPUShaderModules from the currently bound shader program.
*/
DECLSPEC void MOJOSHADER_sdlGetShaders(MOJOSHADER_sdlContext *ctx,
SDL_GpuShader **vshader,
SDL_GpuShader **pshader);
SDL_GPUShader **vshader,
SDL_GPUShader **pshader);

/*
* Gets the number of sampler slots needed by a given shader module.
Expand Down
28 changes: 14 additions & 14 deletions mojoshader_sdlgpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

struct MOJOSHADER_sdlContext
{
SDL_GpuDevice *device;
SDL_GPUDevice *device;
const char *profile;

MOJOSHADER_malloc malloc_fn;
Expand Down Expand Up @@ -58,8 +58,8 @@ struct MOJOSHADER_sdlShaderData

struct MOJOSHADER_sdlProgram
{
SDL_GpuShader *vertexShader;
SDL_GpuShader *pixelShader;
SDL_GPUShader *vertexShader;
SDL_GPUShader *pixelShader;
MOJOSHADER_sdlShaderData *vertexShaderData;
MOJOSHADER_sdlShaderData *pixelShaderData;
};
Expand Down Expand Up @@ -157,7 +157,7 @@ static void nuke_shaders(

static void update_uniform_buffer(
MOJOSHADER_sdlContext *ctx,
SDL_GpuCommandBuffer *cb,
SDL_GPUCommandBuffer *cb,
MOJOSHADER_sdlShaderData *shader
) {
int32_t i, j;
Expand Down Expand Up @@ -237,7 +237,7 @@ static void update_uniform_buffer(

if (shader->parseData->shader_type == MOJOSHADER_TYPE_VERTEX)
{
SDL_PushGpuVertexUniformData(
SDL_PushGPUVertexUniformData(
cb,
0,
contents,
Expand All @@ -246,7 +246,7 @@ static void update_uniform_buffer(
} // if
else
{
SDL_PushGpuFragmentUniformData(
SDL_PushGPUFragmentUniformData(
cb,
0,
contents,
Expand All @@ -265,7 +265,7 @@ unsigned int MOJOSHADER_sdlGetShaderFormats(void)
} // MOJOSHADER_sdlGetShaderFormats

MOJOSHADER_sdlContext *MOJOSHADER_sdlCreateContext(
SDL_GpuDevice *device,
SDL_GPUDevice *device,
MOJOSHADER_malloc m,
MOJOSHADER_free f,
void *malloc_d
Expand Down Expand Up @@ -382,7 +382,7 @@ MOJOSHADER_sdlProgram *MOJOSHADER_sdlLinkProgram(
int vertexAttributeCount
) {
MOJOSHADER_sdlProgram *program = NULL;
SDL_GpuShaderCreateInfo createInfo;
SDL_GPUShaderCreateInfo createInfo;

MOJOSHADER_sdlShaderData *vshader = ctx->bound_vshader_data;
MOJOSHADER_sdlShaderData *pshader = ctx->bound_pshader_data;
Expand Down Expand Up @@ -507,7 +507,7 @@ MOJOSHADER_sdlProgram *MOJOSHADER_sdlLinkProgram(
if (program->pixelShader == NULL)
{
set_error(SDL_GetError());
SDL_ReleaseGpuShader(ctx->device, program->vertexShader);
SDL_ReleaseGPUShader(ctx->device, program->vertexShader);
ctx->free_fn(program, ctx->malloc_data);
return NULL;
} // if
Expand Down Expand Up @@ -590,9 +590,9 @@ void MOJOSHADER_sdlDeleteProgram(
if (ctx->bound_program == p)
ctx->bound_program = NULL;
if (p->vertexShader != NULL)
SDL_ReleaseGpuShader(ctx->device, p->vertexShader);
SDL_ReleaseGPUShader(ctx->device, p->vertexShader);
if (p->pixelShader != NULL)
SDL_ReleaseGpuShader(ctx->device, p->pixelShader);
SDL_ReleaseGPUShader(ctx->device, p->pixelShader);
ctx->free_fn(p, ctx->malloc_data);
} // MOJOSHADER_sdlDeleteProgram

Expand Down Expand Up @@ -661,7 +661,7 @@ int MOJOSHADER_sdlGetUniformBufferSize(MOJOSHADER_sdlShaderData *shader)
} // MOJOSHADER_sdlGetUniformBufferSize

void MOJOSHADER_sdlUpdateUniformBuffers(MOJOSHADER_sdlContext *ctx,
SDL_GpuCommandBuffer *cb)
SDL_GPUCommandBuffer *cb)
{
if (MOJOSHADER_sdlGetUniformBufferSize(ctx->bound_program->vertexShaderData) > 0)
update_uniform_buffer(ctx, cb, ctx->bound_program->vertexShaderData);
Expand Down Expand Up @@ -692,8 +692,8 @@ int MOJOSHADER_sdlGetVertexAttribLocation(

void MOJOSHADER_sdlGetShaders(
MOJOSHADER_sdlContext *ctx,
SDL_GpuShader **vshader,
SDL_GpuShader **pshader
SDL_GPUShader **vshader,
SDL_GPUShader **pshader
) {
assert(ctx->bound_program != NULL);
if (vshader != NULL)
Expand Down
Loading

0 comments on commit 9485200

Please sign in to comment.