Update some features and limits;

- rm dynamicIndexing and nonUniformIndexing, for now (arrays aren't well
  supported)
- rename compressed texture features
- move clip/cull distance to limit instead of feature (limit can be 0)
This commit is contained in:
bjorn 2022-04-26 15:31:51 -07:00
parent 3ae0ff568f
commit 50ebed697e
5 changed files with 28 additions and 40 deletions

View File

@ -39,14 +39,11 @@ static int l_lovrGraphicsGetFeatures(lua_State* L) {
GraphicsFeatures features;
lovrGraphicsGetFeatures(&features);
lua_newtable(L);
lua_pushboolean(L, features.bptc), lua_setfield(L, -2, "bptc");
lua_pushboolean(L, features.astc), lua_setfield(L, -2, "astc");
lua_pushboolean(L, features.textureBC), lua_setfield(L, -2, "textureBC");
lua_pushboolean(L, features.textureASTC), lua_setfield(L, -2, "textureASTC");
lua_pushboolean(L, features.wireframe), lua_setfield(L, -2, "wireframe");
lua_pushboolean(L, features.depthClamp), lua_setfield(L, -2, "depthClamp");
lua_pushboolean(L, features.clipDistance), lua_setfield(L, -2, "clipDistance");
lua_pushboolean(L, features.cullDistance), lua_setfield(L, -2, "cullDistance");
lua_pushboolean(L, features.indirectDrawFirstInstance), lua_setfield(L, -2, "indirectDrawFirstInstance");
lua_pushboolean(L, features.dynamicIndexing), lua_setfield(L, -2, "dynamicIndexing");
lua_pushboolean(L, features.float64), lua_setfield(L, -2, "float64");
lua_pushboolean(L, features.int64), lua_setfield(L, -2, "int64");
lua_pushboolean(L, features.int16), lua_setfield(L, -2, "int16");
@ -77,6 +74,10 @@ static int l_lovrGraphicsGetLimits(lua_State* L) {
lua_pushinteger(L, limits.vertexBufferStride), lua_setfield(L, -2, "vertexBufferStride");
lua_pushinteger(L, limits.vertexShaderOutputs), lua_setfield(L, -2, "vertexShaderOutputs");
lua_pushinteger(L, limits.clipDistances), lua_setfield(L, -2, "clipDistances");
lua_pushinteger(L, limits.cullDistances), lua_setfield(L, -2, "cullDistances");
lua_pushinteger(L, limits.clipAndCullDistances), lua_setfield(L, -2, "clipAndCullDistances");
lua_createtable(L, 3, 0);
lua_pushinteger(L, limits.computeDispatchCount[0]), lua_rawseti(L, -2, 1);
lua_pushinteger(L, limits.computeDispatchCount[1]), lua_rawseti(L, -2, 2);

View File

@ -11,14 +11,11 @@ typedef struct {
} gpu_device_info;
typedef struct {
bool bptc;
bool astc;
bool textureBC;
bool textureASTC;
bool wireframe;
bool depthClamp;
bool clipDistance;
bool cullDistance;
bool indirectDrawFirstInstance;
bool dynamicIndexing;
bool float64;
bool int64;
bool int16;
@ -38,6 +35,9 @@ typedef struct {
uint32_t vertexBuffers;
uint32_t vertexBufferStride;
uint32_t vertexShaderOutputs;
uint32_t clipDistances;
uint32_t cullDistances;
uint32_t clipAndCullDistances;
uint32_t computeDispatchCount[3];
uint32_t computeWorkgroupSize[3];
uint32_t computeWorkgroupVolume;

View File

@ -255,6 +255,9 @@ bool gpu_init(gpu_config* config) {
config->limits->vertexBuffers = limits->maxVertexInputBindings;
config->limits->vertexBufferStride = MIN(limits->maxVertexInputBindingStride, UINT16_MAX);
config->limits->vertexShaderOutputs = limits->maxVertexOutputComponents;
config->limits->clipDistances = limits->maxClipDistances;
config->limits->cullDistances = limits->maxCullDistances;
config->limits->clipAndCullDistances = limits->maxCombinedClipAndCullDistances;
config->limits->computeDispatchCount[0] = limits->maxComputeWorkGroupCount[0];
config->limits->computeDispatchCount[1] = limits->maxComputeWorkGroupCount[1];
config->limits->computeDispatchCount[2] = limits->maxComputeWorkGroupCount[2];
@ -298,33 +301,19 @@ bool gpu_init(gpu_config* config) {
// Internal features (exposed as limits)
enable->samplerAnisotropy = supports->samplerAnisotropy;
enable->multiDrawIndirect = supports->multiDrawIndirect;
enable->shaderClipDistance = supports->shaderClipDistance;
enable->shaderCullDistance = supports->shaderCullDistance;
enable->largePoints = supports->largePoints;
// Optional features (currently always enabled when supported)
config->features->astc = enable->textureCompressionASTC_LDR = supports->textureCompressionASTC_LDR;
config->features->bptc = enable->textureCompressionBC = supports->textureCompressionBC;
config->features->textureBC = enable->textureCompressionBC = supports->textureCompressionBC;
config->features->textureASTC = enable->textureCompressionASTC_LDR = supports->textureCompressionASTC_LDR;
config->features->wireframe = enable->fillModeNonSolid = supports->fillModeNonSolid;
config->features->depthClamp = enable->depthClamp = supports->depthClamp;
config->features->clipDistance = enable->shaderClipDistance = supports->shaderClipDistance;
config->features->cullDistance = enable->shaderCullDistance = supports->shaderCullDistance;
config->features->indirectDrawFirstInstance = enable->drawIndirectFirstInstance = supports->drawIndirectFirstInstance;
config->features->float64 = enable->shaderFloat64 = supports->shaderFloat64;
config->features->int64 = enable->shaderInt64 = supports->shaderInt64;
config->features->int16 = enable->shaderInt16 = supports->shaderInt16;
bool dynamicIndexing =
supports->shaderUniformBufferArrayDynamicIndexing &&
supports->shaderSampledImageArrayDynamicIndexing &&
supports->shaderStorageBufferArrayDynamicIndexing &&
supports->shaderStorageImageArrayDynamicIndexing;
if (dynamicIndexing) {
enable->shaderUniformBufferArrayDynamicIndexing = true;
enable->shaderSampledImageArrayDynamicIndexing = true;
enable->shaderStorageBufferArrayDynamicIndexing = true;
enable->shaderStorageImageArrayDynamicIndexing = true;
config->features->dynamicIndexing = true;
}
}
state.queueFamilyIndex = ~0u;

View File

@ -51,14 +51,11 @@ void lovrGraphicsGetDevice(GraphicsDevice* device) {
}
void lovrGraphicsGetFeatures(GraphicsFeatures* features) {
features->bptc = state.features.bptc;
features->astc = state.features.astc;
features->textureBC = state.features.textureBC;
features->textureASTC = state.features.textureASTC;
features->wireframe = state.features.wireframe;
features->depthClamp = state.features.depthClamp;
features->clipDistance = state.features.clipDistance;
features->cullDistance = state.features.cullDistance;
features->indirectDrawFirstInstance = state.features.indirectDrawFirstInstance;
features->dynamicIndexing = state.features.dynamicIndexing;
features->float64 = state.features.float64;
features->int64 = state.features.int64;
features->int16 = state.features.int16;
@ -79,6 +76,9 @@ void lovrGraphicsGetLimits(GraphicsLimits* limits) {
limits->vertexAttributes = state.limits.vertexAttributes;
limits->vertexBufferStride = state.limits.vertexBufferStride;
limits->vertexShaderOutputs = state.limits.vertexShaderOutputs;
limits->clipDistances = state.limits.clipDistances;
limits->cullDistances = state.limits.cullDistances;
limits->clipAndCullDistances = state.limits.clipAndCullDistances;
memcpy(limits->computeDispatchCount, state.limits.computeDispatchCount, 3 * sizeof(uint32_t));
memcpy(limits->computeWorkgroupSize, state.limits.computeWorkgroupSize, 3 * sizeof(uint32_t));
limits->computeWorkgroupVolume = state.limits.computeWorkgroupVolume;

View File

@ -13,16 +13,11 @@ typedef struct {
} GraphicsDevice;
typedef struct {
bool bptc;
bool astc;
bool textureBC;
bool textureASTC;
bool wireframe;
bool depthClamp;
bool clipDistance;
bool cullDistance;
bool fullIndexBufferRange;
bool indirectDrawFirstInstance;
bool dynamicIndexing;
bool nonUniformIndexing;
bool float64;
bool int64;
bool int16;
@ -41,6 +36,9 @@ typedef struct {
uint32_t vertexAttributes;
uint32_t vertexBufferStride;
uint32_t vertexShaderOutputs;
uint32_t clipDistances;
uint32_t cullDistances;
uint32_t clipAndCullDistances;
uint32_t computeDispatchCount[3];
uint32_t computeWorkgroupSize[3];
uint32_t computeWorkgroupVolume;