Enforce maximum spirv version;

This commit is contained in:
bjorn 2022-05-31 20:47:47 -07:00
parent a2cc4f3495
commit ab04577495
3 changed files with 4 additions and 0 deletions

View File

@ -68,6 +68,8 @@ spv_result spv_parse(const void* source, uint32_t size, spv_info* info) {
return SPV_INVALID;
}
info->version = spv.words[1];
spv.bound = spv.words[3];
if (spv.bound >= 0xffff) {

View File

@ -50,6 +50,7 @@ typedef struct {
} spv_resource;
typedef struct {
uint32_t version;
uint32_t inputLocationMask;
uint32_t featureCount;
uint32_t specConstantCount;

View File

@ -1024,6 +1024,7 @@ Shader* lovrShaderCreate(ShaderInfo* info) {
for (uint32_t i = 0; i < stageCount; i++) {
result = spv_parse(info->stages[i]->data, info->stages[i]->size, &spv[i]);
lovrCheck(result == SPV_OK, "Failed to load Shader: %s\n", spv_result_to_string(result));
lovrCheck(spv[i].version <= 0x00010300, "Invalid SPIR-V version (up to 1.3 is supported)");
spv[i].features = tempAlloc(spv[i].featureCount * sizeof(uint32_t));
spv[i].specConstants = tempAlloc(spv[i].specConstantCount * sizeof(spv_spec_constant));