mirror of https://github.com/bjornbytes/lovr.git
Pass:send supports push constants;
This commit is contained in:
parent
8effa7424f
commit
a8b35074e0
|
@ -152,6 +152,7 @@ void* luax_readfile(const char* filename, size_t* bytesRead);
|
||||||
|
|
||||||
#ifndef LOVR_DISABLE_GRAPHICS
|
#ifndef LOVR_DISABLE_GRAPHICS
|
||||||
struct Buffer;
|
struct Buffer;
|
||||||
|
void luax_readbufferfield(struct lua_State* L, int index, int type, void* data);
|
||||||
void luax_readbufferdata(struct lua_State* L, int index, struct Buffer* buffer, char* data);
|
void luax_readbufferdata(struct lua_State* L, int index, struct Buffer* buffer, char* data);
|
||||||
uint32_t luax_checkcomparemode(struct lua_State* L, int index);
|
uint32_t luax_checkcomparemode(struct lua_State* L, int index);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -61,7 +61,7 @@ typedef union {
|
||||||
float* f32;
|
float* f32;
|
||||||
} FieldPointer;
|
} FieldPointer;
|
||||||
|
|
||||||
static void luax_readbufferfield(lua_State* L, int index, int type, void* data) {
|
void luax_readbufferfield(lua_State* L, int index, int type, void* data) {
|
||||||
FieldPointer p = { .raw = data };
|
FieldPointer p = { .raw = data };
|
||||||
if (lua_isuserdata(L, index)) {
|
if (lua_isuserdata(L, index)) {
|
||||||
VectorType vectorType;
|
VectorType vectorType;
|
||||||
|
|
|
@ -337,7 +337,15 @@ static int l_lovrPassSend(lua_State* L) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return luax_typeerror(L, 3, "Buffer, Texture, Sampler, or number/vector");
|
if (!name) {
|
||||||
|
return luax_typeerror(L, 3, "Buffer, Texture, or Sampler");
|
||||||
|
}
|
||||||
|
|
||||||
|
void* data;
|
||||||
|
FieldType type;
|
||||||
|
lovrPassSendValue(pass, name, length, &data, &type);
|
||||||
|
luax_readbufferfield(L, 3, type, data);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t luax_getvertexcount(lua_State* L, int index) {
|
static uint32_t luax_getvertexcount(lua_State* L, int index) {
|
||||||
|
|
|
@ -1889,6 +1889,22 @@ void lovrPassSendSampler(Pass* pass, const char* name, size_t length, uint32_t s
|
||||||
pass->bindingsDirty = true;
|
pass->bindingsDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lovrPassSendValue(Pass* pass, const char* name, size_t length, void** data, FieldType* type) {
|
||||||
|
Shader* shader = pass->pipeline->shader;
|
||||||
|
lovrCheck(shader, "A Shader must be active to send resources");
|
||||||
|
|
||||||
|
uint32_t hash = (uint32_t) hash64(name, length);
|
||||||
|
for (uint32_t i = 0; i < shader->constantCount; i++) {
|
||||||
|
if (shader->constants[i].hash == hash) {
|
||||||
|
*data = (char*) pass->constants + shader->constants[i].offset;
|
||||||
|
*type = shader->constants[i].type;
|
||||||
|
pass->constantsDirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lovrThrow("Shader has no push constant named '%s'", name);
|
||||||
|
}
|
||||||
|
|
||||||
static void flushPipeline(Pass* pass, Draw* draw, Shader* shader) {
|
static void flushPipeline(Pass* pass, Draw* draw, Shader* shader) {
|
||||||
Pipeline* pipeline = pass->pipeline;
|
Pipeline* pipeline = pass->pipeline;
|
||||||
|
|
||||||
|
|
|
@ -388,6 +388,7 @@ void lovrPassSetWireframe(Pass* pass, bool wireframe);
|
||||||
void lovrPassSendBuffer(Pass* pass, const char* name, size_t length, uint32_t slot, Buffer* buffer, uint32_t offset, uint32_t extent);
|
void lovrPassSendBuffer(Pass* pass, const char* name, size_t length, uint32_t slot, Buffer* buffer, uint32_t offset, uint32_t extent);
|
||||||
void lovrPassSendTexture(Pass* pass, const char* name, size_t length, uint32_t slot, Texture* texture);
|
void lovrPassSendTexture(Pass* pass, const char* name, size_t length, uint32_t slot, Texture* texture);
|
||||||
void lovrPassSendSampler(Pass* pass, const char* name, size_t length, uint32_t slot, Sampler* sampler);
|
void lovrPassSendSampler(Pass* pass, const char* name, size_t length, uint32_t slot, Sampler* sampler);
|
||||||
|
void lovrPassSendValue(Pass* pass, const char* name, size_t length, void** data, FieldType* type);
|
||||||
void lovrPassPoints(Pass* pass, uint32_t count, float** vertices);
|
void lovrPassPoints(Pass* pass, uint32_t count, float** vertices);
|
||||||
void lovrPassLine(Pass* pass, uint32_t count, float** vertices);
|
void lovrPassLine(Pass* pass, uint32_t count, float** vertices);
|
||||||
void lovrPassPlane(Pass* pass, float* transform, uint32_t cols, uint32_t rows);
|
void lovrPassPlane(Pass* pass, float* transform, uint32_t cols, uint32_t rows);
|
||||||
|
|
Loading…
Reference in New Issue