Skip to content

Commit

Permalink
gx2: Add GX2Get{Geometry,Vertex,Pixel}Uniform{Block,Var}.
Browse files Browse the repository at this point in the history
  • Loading branch information
exjam committed Nov 19, 2019
1 parent f2f82b1 commit f0ed4fb
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions include/gx2/shaders.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include <string.h>
#include <wut.h>
#include "enum.h"
#include "sampler.h"
Expand Down Expand Up @@ -459,6 +460,84 @@ GX2GetGeometryShaderGPRs(GX2GeometryShader *shader);
uint32_t
GX2GetGeometryShaderStackEntries(GX2GeometryShader *shader);

static inline GX2UniformBlock *
GX2GetGeometryUniformBlock(const GX2GeometryShader *shader,
const char *name)
{
for (uint32_t i = 0; i < shader->uniformBlockCount; ++i) {
if (strcmp(name, shader->uniformBlocks[i].name) == 0) {
return &shader->uniformBlocks[i];
}
}

return NULL;
}

static inline GX2UniformBlock *
GX2GetPixelUniformBlock(const GX2PixelShader *shader,
const char *name)
{
for (uint32_t i = 0; i < shader->uniformBlockCount; ++i) {
if (strcmp(name, shader->uniformBlocks[i].name) == 0) {
return &shader->uniformBlocks[i];
}
}

return NULL;
}

static inline GX2UniformBlock *
GX2GetVertexUniformBlock(const GX2VertexShader *shader,
const char *name)
{
for (uint32_t i = 0; i < shader->uniformBlockCount; ++i) {
if (strcmp(name, shader->uniformBlocks[i].name) == 0) {
return &shader->uniformBlocks[i];
}
}

return NULL;
}

static inline GX2UniformVar *
GX2GetGeometryUniformVar(const GX2GeometryShader *shader,
const char *name)
{
for (uint32_t i = 0; i < shader->uniformVarCount; ++i) {
if (strcmp(name, shader->uniformVars[i].name) == 0) {
return &shader->uniformVars[i];
}
}

return NULL;
}

static inline GX2UniformVar *
GX2GetPixelUniformVar(const GX2PixelShader *shader,
const char *name)
{
for (uint32_t i = 0; i < shader->uniformVarCount; ++i) {
if (strcmp(name, shader->uniformVars[i].name) == 0) {
return &shader->uniformVars[i];
}
}

return NULL;
}

static inline GX2UniformVar *
GX2GetVertexUniformVar(const GX2VertexShader *shader,
const char *name)
{
for (uint32_t i = 0; i < shader->uniformVarCount; ++i) {
if (strcmp(name, shader->uniformVars[i].name) == 0) {
return &shader->uniformVars[i];
}
}

return NULL;
}

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit f0ed4fb

Please sign in to comment.