EXT_ray_tracing requires spv1.4 (#2237)

* EXT_ray_tracing requires spv1.4

* Fix typo.

* Add extension data table.

* Updated feedback #2.
This commit is contained in:
alelenv 2020-05-28 08:18:07 -07:00 committed by GitHub
parent d0c9129d2f
commit d39b8afc47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 91 additions and 37 deletions

View File

@ -1,5 +1,5 @@
spv.ext.AnyHitShader.rahit
// Module Version 10000
// Module Version 10400
// Generated by (magic number): 80008
// Id's are bound by 94
@ -7,7 +7,7 @@ spv.ext.AnyHitShader.rahit
Extension "SPV_KHR_ray_tracing"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint AnyHitKHR 4 "main" 11 14 20 23 26 33 36 39 42 47 50 53 58 64 67 70 76 80
EntryPoint AnyHitKHR 4 "main" 11 14 20 23 26 33 36 39 42 47 50 53 58 64 67 70 76 80 84
Source GLSL 460
SourceExtension "GL_EXT_ray_tracing"
Name 4 "main"

View File

@ -1,5 +1,5 @@
spv.ext.ClosestHitShader.rchit
// Module Version 10000
// Module Version 10400
// Generated by (magic number): 80008
// Id's are bound by 101
@ -7,7 +7,7 @@ spv.ext.ClosestHitShader.rchit
Extension "SPV_KHR_ray_tracing"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint ClosestHitKHR 4 "main" 11 14 20 23 26 33 36 39 42 47 50 53 58 64 67 70 76 80
EntryPoint ClosestHitKHR 4 "main" 11 14 20 23 26 33 36 39 42 47 50 53 58 64 67 70 76 80 85 98 100
Source GLSL 460
SourceExtension "GL_EXT_ray_tracing"
Name 4 "main"

View File

@ -1,5 +1,5 @@
spv.ext.IntersectShader.rint
// Module Version 10000
// Module Version 10400
// Generated by (magic number): 80008
// Id's are bound by 81
@ -7,7 +7,7 @@ spv.ext.IntersectShader.rint
Extension "SPV_KHR_ray_tracing"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint IntersectionKHR 4 "main" 11 14 20 23 26 33 36 39 42 47 50 56 59 65 69
EntryPoint IntersectionKHR 4 "main" 11 14 20 23 26 33 36 39 42 47 50 56 59 65 69 73
Source GLSL 460
SourceExtension "GL_EXT_ray_tracing"
Name 4 "main"

View File

@ -1,5 +1,5 @@
spv.ext.MissShader.rmiss
// Module Version 10000
// Module Version 10400
// Generated by (magic number): 80008
// Id's are bound by 54
@ -7,7 +7,7 @@ spv.ext.MissShader.rmiss
Extension "SPV_KHR_ray_tracing"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint MissKHR 4 "main" 11 14 21 24 29 32
EntryPoint MissKHR 4 "main" 11 14 21 24 29 32 36 51 53
Source GLSL 460
SourceExtension "GL_EXT_ray_tracing"
Name 4 "main"

View File

@ -1,5 +1,5 @@
spv.ext.RayCallable.rcall
// Module Version 10000
// Module Version 10400
// Generated by (magic number): 80008
// Id's are bound by 30
@ -7,7 +7,7 @@ spv.ext.RayCallable.rcall
Extension "SPV_KHR_ray_tracing"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint CallableKHR 4 "main" 11 14
EntryPoint CallableKHR 4 "main" 11 14 18 29
Source GLSL 460
SourceExtension "GL_EXT_ray_tracing"
Name 4 "main"

View File

@ -1,5 +1,5 @@
spv.ext.RayConstants.rgen
// Module Version 10000
// Module Version 10400
// Generated by (magic number): 80008
// Id's are bound by 27
@ -7,7 +7,7 @@ spv.ext.RayConstants.rgen
Extension "SPV_KHR_ray_tracing"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint RayGenerationKHR 4 "main"
EntryPoint RayGenerationKHR 4 "main" 8 26
Source GLSL 460
SourceExtension "GL_EXT_ray_tracing"
Name 4 "main"

View File

@ -1,5 +1,5 @@
spv.ext.RayGenShader.rgen
// Module Version 10000
// Module Version 10400
// Generated by (magic number): 80008
// Id's are bound by 58
@ -8,7 +8,7 @@ spv.ext.RayGenShader.rgen
Extension "SPV_KHR_ray_tracing"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint RayGenerationKHR 4 "main" 11 21
EntryPoint RayGenerationKHR 4 "main" 11 21 29 40 51 54 57
Source GLSL 460
SourceExtension "GL_EXT_ray_flags_primitive_culling"
SourceExtension "GL_EXT_ray_tracing"
@ -33,7 +33,7 @@ spv.ext.RayGenShader.rgen
Decorate 29(accEXT0) Binding 0
MemberDecorate 38(block) 0 Offset 0
MemberDecorate 38(block) 1 Offset 16
Decorate 38(block) BufferBlock
Decorate 38(block) Block
Decorate 51(accEXT1) DescriptorSet 0
Decorate 51(accEXT1) Binding 1
Decorate 54(imageu) DescriptorSet 0

View File

@ -1,5 +1,5 @@
spv.ext.RayGenShader11.rgen
// Module Version 10000
// Module Version 10400
// Generated by (magic number): 80008
// Id's are bound by 53
@ -7,7 +7,7 @@ spv.ext.RayGenShader11.rgen
Extension "SPV_KHR_ray_tracing"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint RayGenerationKHR 4 "main" 11 21
EntryPoint RayGenerationKHR 4 "main" 11 21 29 39 52
Source GLSL 460
SourceExtension "GL_EXT_ray_tracing"
Name 4 "main"
@ -29,7 +29,7 @@ spv.ext.RayGenShader11.rgen
Decorate 29(accEXT) Binding 0
MemberDecorate 37(block) 0 Offset 0
MemberDecorate 37(block) 1 Offset 16
Decorate 37(block) BufferBlock
Decorate 37(block) Block
Decorate 52(payload) Location 0
2: TypeVoid
3: TypeFunction 2

View File

@ -1,5 +1,5 @@
spv.ext.RayGenShaderArray.rgen
// Module Version 10000
// Module Version 10400
// Generated by (magic number): 80008
// Id's are bound by 89
@ -10,7 +10,7 @@ spv.ext.RayGenShaderArray.rgen
Extension "SPV_KHR_ray_tracing"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint RayGenerationKHR 4 "main" 11 21
EntryPoint RayGenerationKHR 4 "main" 11 21 30 36 60 88
Source GLSL 460
SourceExtension "GL_EXT_nonuniform_qualifier"
SourceExtension "GL_EXT_ray_tracing"
@ -36,7 +36,7 @@ spv.ext.RayGenShaderArray.rgen
MemberDecorate 34(block) 0 Offset 0
MemberDecorate 34(block) 1 Offset 16
MemberDecorate 34(block) 2 Offset 28
Decorate 34(block) BufferBlock
Decorate 34(block) Block
Decorate 60(accEXT1) DescriptorSet 0
Decorate 60(accEXT1) Binding 1
Decorate 75 DecorationNonUniformEXT

View File

@ -64,6 +64,7 @@
// checkDeprecated()
// requireNotRemoved()
// requireExtensions()
// extensionRequires()
//
// Typically, only the first two calls are needed. They go into a code path that
// implements Feature F, and will log the proper error/warning messages. Parsing
@ -78,9 +79,11 @@
// const char* const XXX_extension_X = "XXX_extension_X";
//
// 2) Add extension initialization to TParseVersions::initializeExtensionBehavior(),
// the first function below:
// the first function below and optionally a entry to extensionData for additional
// error checks:
//
// extensionBehavior[XXX_extension_X] = EBhDisable;
// (Optional) exts[] = {XXX_extension_X, EShTargetSpv_1_4}
//
// 3) Add any preprocessor directives etc. in the next function, TParseVersions::getPreamble():
//
@ -140,6 +143,8 @@
// set of extensions that both enable them and are necessary, given the version of the symbol
// table. (There is a different symbol table for each version.)
//
// 7) If the extension has additional requirements like minimum SPIR-V version required, add them
// to extensionRequires()
#include "parseVersions.h"
#include "localintermediate.h"
@ -155,6 +160,20 @@ namespace glslang {
//
void TParseVersions::initializeExtensionBehavior()
{
typedef struct {
const char *const extensionName;
EShTargetLanguageVersion minSpvVersion;
} extensionData;
const extensionData exts[] = { {E_GL_EXT_ray_tracing, EShTargetSpv_1_4} };
for (int ii = 0; ii < sizeof(exts) / sizeof(exts[0]); ii++) {
// Add only extensions which require > spv1.0 to save space in map
if (exts[ii].minSpvVersion > EShTargetSpv_1_0) {
extensionMinSpv[E_GL_EXT_ray_tracing] = exts[ii].minSpvVersion;
}
}
extensionBehavior[E_GL_OES_texture_3D] = EBhDisable;
extensionBehavior[E_GL_OES_standard_derivatives] = EBhDisable;
extensionBehavior[E_GL_EXT_frag_depth] = EBhDisable;
@ -329,6 +348,7 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_EXT_shader_subgroup_extended_types_int64] = EBhDisable;
extensionBehavior[E_GL_EXT_shader_subgroup_extended_types_float16] = EBhDisable;
}
#endif // GLSLANG_WEB
// Get code that is not part of a shared symbol table, is specific to this shader,
@ -828,6 +848,9 @@ void TParseVersions::updateExtensionBehavior(int line, const char* extension, co
// check if extension is used with correct shader stage
checkExtensionStage(getCurrentLoc(), extension);
// check if extension has additional requirements
extensionRequires(getCurrentLoc(), extension ,behaviorString);
// update the requested extension
updateExtensionBehavior(extension, behavior);
@ -944,6 +967,24 @@ void TParseVersions::checkExtensionStage(const TSourceLoc& loc, const char * con
}
}
// Check if extension has additional requirements
void TParseVersions::extensionRequires(const TSourceLoc &loc, const char * const extension, const char *behaviorString)
{
bool isEnabled = false;
if (!strcmp("require", behaviorString))
isEnabled = true;
else if (!strcmp("enable", behaviorString))
isEnabled = true;
if (isEnabled) {
unsigned int minSpvVersion = 0;
auto iter = extensionMinSpv.find(TString(extension));
if (iter != extensionMinSpv.end())
minSpvVersion = iter->second;
requireSpv(loc, extension, minSpvVersion);
}
}
// Call for any operation needing full GLSL integer data-type support.
void TParseVersions::fullIntegerCheck(const TSourceLoc& loc, const char* op)
{
@ -1201,5 +1242,12 @@ void TParseVersions::requireSpv(const TSourceLoc& loc, const char* op)
error(loc, "only allowed when generating SPIR-V", op, "");
#endif
}
void TParseVersions::requireSpv(const TSourceLoc& loc, const char *op, unsigned int version)
{
#ifndef GLSLANG_WEB
if (spvVersion.spv < version)
error(loc, "not supported for current targeted SPIR-V version", op, "");
#endif
}
} // end namespace glslang

View File

@ -36,6 +36,7 @@
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _VERSIONS_INCLUDED_
#define _VERSIONS_INCLUDED_

View File

@ -101,6 +101,7 @@ public:
void updateExtensionBehavior(int line, const char* const extension, const char* behavior) { }
void updateExtensionBehavior(const char* const extension, TExtensionBehavior) { }
void checkExtensionStage(const TSourceLoc&, const char* const extension) { }
void extensionRequires(const TSourceLoc&, const char* const extension, const char* behavior) { }
void fullIntegerCheck(const TSourceLoc&, const char* op) { }
void doubleCheck(const TSourceLoc&, const char* op) { }
bool float16Arithmetic() { return false; }
@ -139,6 +140,7 @@ public:
virtual bool checkExtensionsRequested(const TSourceLoc&, int numExtensions, const char* const extensions[],
const char* featureDesc);
virtual void checkExtensionStage(const TSourceLoc&, const char* const extension);
virtual void extensionRequires(const TSourceLoc&, const char* const extension, const char* behavior);
virtual void fullIntegerCheck(const TSourceLoc&, const char* op);
virtual void unimplemented(const TSourceLoc&, const char* featureDesc);
@ -170,6 +172,7 @@ public:
virtual void vulkanRemoved(const TSourceLoc&, const char* op);
virtual void requireVulkan(const TSourceLoc&, const char* op);
virtual void requireSpv(const TSourceLoc&, const char* op);
virtual void requireSpv(const TSourceLoc&, const char *op, unsigned int version);
#if defined(GLSLANG_WEB) && !defined(GLSLANG_WEB_DEVEL)
@ -222,6 +225,7 @@ public:
protected:
TMap<TString, TExtensionBehavior> extensionBehavior; // for each extension string, what its current behavior is set to
TMap<TString, unsigned int> extensionMinSpv; // for each extension string, store minimum spirv required
EShMessages messages; // errors/warnings/rule-sets
int numErrors; // number of compile-time errors encountered
TInputScanner* currentScanner;

View File

@ -413,6 +413,7 @@ enum TResourceType {
EResCount
};
// Make one TShader per shader that you will link into a program. Then
// - provide the shader through setStrings() or setStringsWithLengths()
// - optionally call setEnv*(), see below for more detail

View File

@ -329,21 +329,6 @@ INSTANTIATE_TEST_CASE_P(
"spv.earlyReturnDiscard.frag",
"spv.extPostDepthCoverage.frag",
"spv.extPostDepthCoverage_Error.frag",
"spv.ext.AnyHitShader.rahit",
"spv.ext.AnyHitShader_Errors.rahit",
"spv.ext.ClosestHitShader.rchit",
"spv.ext.ClosestHitShader_Errors.rchit",
"spv.ext.IntersectShader.rint",
"spv.ext.IntersectShader_Errors.rint",
"spv.ext.MissShader.rmiss",
"spv.ext.MissShader_Errors.rmiss",
"spv.ext.RayPrimCull_Errors.rgen",
"spv.ext.RayCallable.rcall",
"spv.ext.RayCallable_Errors.rcall",
"spv.ext.RayConstants.rgen",
"spv.ext.RayGenShader.rgen",
"spv.ext.RayGenShader11.rgen",
"spv.ext.RayGenShaderArray.rgen",
"spv.float16convertonlyarith.comp",
"spv.float16convertonlystorage.comp",
"spv.flowControl.frag",
@ -554,6 +539,21 @@ INSTANTIATE_TEST_CASE_P(
"spv.1.4.sparseTexture.frag",
"spv.1.4.texture.frag",
"spv.1.4.constructComposite.comp",
"spv.ext.AnyHitShader.rahit",
"spv.ext.AnyHitShader_Errors.rahit",
"spv.ext.ClosestHitShader.rchit",
"spv.ext.ClosestHitShader_Errors.rchit",
"spv.ext.IntersectShader.rint",
"spv.ext.IntersectShader_Errors.rint",
"spv.ext.MissShader.rmiss",
"spv.ext.MissShader_Errors.rmiss",
"spv.ext.RayPrimCull_Errors.rgen",
"spv.ext.RayCallable.rcall",
"spv.ext.RayCallable_Errors.rcall",
"spv.ext.RayConstants.rgen",
"spv.ext.RayGenShader.rgen",
"spv.ext.RayGenShader11.rgen",
"spv.ext.RayGenShaderArray.rgen",
})),
FileNameAsCustomTestSuffix
);