mirror of https://github.com/bjornbytes/lovr.git
Add compute dispatch limit;
This commit is contained in:
parent
4f730a89a7
commit
c7ca7eaa38
|
@ -451,6 +451,14 @@ static int l_lovrGraphicsGetLimits(lua_State* L) {
|
|||
lua_setfield(L, -2, "anisotropy");
|
||||
lua_pushinteger(L, limits->blockSize);
|
||||
lua_setfield(L, -2, "blocksize");
|
||||
lua_createtable(L, 3, 0);
|
||||
lua_pushinteger(L, limits->compute[0]);
|
||||
lua_rawseti(L, -2, 1);
|
||||
lua_pushinteger(L, limits->compute[1]);
|
||||
lua_rawseti(L, -2, 2);
|
||||
lua_pushinteger(L, limits->compute[2]);
|
||||
lua_rawseti(L, -2, 3);
|
||||
lua_setfield(L, -2, "compute");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -189,13 +189,13 @@ typedef struct {
|
|||
} GpuFeatures;
|
||||
|
||||
typedef struct {
|
||||
bool initialized;
|
||||
float pointSizes[2];
|
||||
int textureSize;
|
||||
int textureMSAA;
|
||||
float textureAnisotropy;
|
||||
int blockSize;
|
||||
int blockAlign;
|
||||
int compute[3];
|
||||
} GpuLimits;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -1263,6 +1263,12 @@ void lovrGpuInit(void* (*getProcAddress)(const char*), bool debug) {
|
|||
#endif
|
||||
glGetFloatv(GL_POINT_SIZE_RANGE, state.limits.pointSizes);
|
||||
|
||||
if (state.features.compute) {
|
||||
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 0, &state.limits.compute[0]);
|
||||
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 1, &state.limits.compute[1]);
|
||||
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 2, &state.limits.compute[2]);
|
||||
}
|
||||
|
||||
if (state.features.multiview) {
|
||||
state.singlepass = MULTIVIEW;
|
||||
} else if (state.features.instancedStereo) {
|
||||
|
@ -1395,6 +1401,9 @@ void lovrGpuCompute(Shader* shader, int x, int y, int z) {
|
|||
#else
|
||||
lovrAssert(state.features.compute, "Compute shaders are not supported on this system");
|
||||
lovrAssert(shader->type == SHADER_COMPUTE, "Attempt to use a non-compute shader for a compute operation");
|
||||
lovrAssert(x <= state.limits.compute[0], "Compute x size %d exceeds the maximum of %d", state.limits.compute[0]);
|
||||
lovrAssert(y <= state.limits.compute[1], "Compute y size %d exceeds the maximum of %d", state.limits.compute[1]);
|
||||
lovrAssert(z <= state.limits.compute[2], "Compute z size %d exceeds the maximum of %d", state.limits.compute[2]);
|
||||
lovrGraphicsFlush();
|
||||
lovrGpuBindShader(shader);
|
||||
glDispatchCompute(x, y, z);
|
||||
|
|
Loading…
Reference in New Issue