Implement GL_EXT_shader_16bit_storage and GL_EXT_shader_8bit_storage extensions.
These introduce limited support for 8/16-bit types such that they can only be accessed in buffer memory and converted to/from 32-bit types. Contributed from Khronos-internal work.
This commit is contained in:
parent
eefab240f7
commit
312dcfb070
43 changed files with 6179 additions and 2765 deletions
|
|
@ -202,6 +202,9 @@ void TParseVersions::initializeExtensionBehavior()
|
|||
extensionBehavior[E_GL_EXT_nonuniform_qualifier] = EBhDisable;
|
||||
extensionBehavior[E_GL_EXT_samplerless_texture_functions] = EBhDisable;
|
||||
|
||||
extensionBehavior[E_GL_EXT_shader_16bit_storage] = EBhDisable;
|
||||
extensionBehavior[E_GL_EXT_shader_8bit_storage] = EBhDisable;
|
||||
|
||||
// #line and #include
|
||||
extensionBehavior[E_GL_GOOGLE_cpp_style_line_directive] = EBhDisable;
|
||||
extensionBehavior[E_GL_GOOGLE_include_directive] = EBhDisable;
|
||||
|
|
@ -363,6 +366,8 @@ void TParseVersions::getPreamble(std::string& preamble)
|
|||
"#define GL_EXT_post_depth_coverage 1\n"
|
||||
"#define GL_EXT_control_flow_attributes 1\n"
|
||||
"#define GL_EXT_nonuniform_qualifier 1\n"
|
||||
"#define GL_EXT_shader_16bit_storage 1\n"
|
||||
"#define GL_EXT_shader_8bit_storage 1\n"
|
||||
"#define GL_EXT_samplerless_texture_functions 1\n"
|
||||
|
||||
// GL_KHR_shader_subgroup
|
||||
|
|
@ -813,27 +818,94 @@ void TParseVersions::fullIntegerCheck(const TSourceLoc& loc, const char* op)
|
|||
void TParseVersions::doubleCheck(const TSourceLoc& loc, const char* op)
|
||||
{
|
||||
requireProfile(loc, ECoreProfile | ECompatibilityProfile, op);
|
||||
profileRequires(loc, ECoreProfile, 400, nullptr, op);
|
||||
profileRequires(loc, ECompatibilityProfile, 400, nullptr, op);
|
||||
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 400, nullptr, op);
|
||||
}
|
||||
|
||||
// Call for any operation needing GLSL float16 data-type support.
|
||||
void TParseVersions::float16Check(const TSourceLoc& loc, const char* op, bool builtIn)
|
||||
{
|
||||
if (!builtIn) {
|
||||
const char* const extensions[] = {
|
||||
#if AMD_EXTENSIONS
|
||||
const char* const extensions[3] = {E_GL_AMD_gpu_shader_half_float,
|
||||
E_GL_AMD_gpu_shader_half_float,
|
||||
#endif
|
||||
E_GL_KHX_shader_explicit_arithmetic_types,
|
||||
E_GL_KHX_shader_explicit_arithmetic_types_float16};
|
||||
requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, "explicit types");
|
||||
}
|
||||
}
|
||||
|
||||
bool TParseVersions::float16Arithmetic()
|
||||
{
|
||||
const char* const extensions[] = {
|
||||
#if AMD_EXTENSIONS
|
||||
E_GL_AMD_gpu_shader_half_float,
|
||||
#endif
|
||||
E_GL_KHX_shader_explicit_arithmetic_types,
|
||||
E_GL_KHX_shader_explicit_arithmetic_types_float16};
|
||||
return extensionsTurnedOn(sizeof(extensions)/sizeof(extensions[0]), extensions);
|
||||
}
|
||||
|
||||
bool TParseVersions::int16Arithmetic()
|
||||
{
|
||||
const char* const extensions[] = {
|
||||
#if AMD_EXTENSIONS
|
||||
E_GL_AMD_gpu_shader_int16,
|
||||
#endif
|
||||
E_GL_KHX_shader_explicit_arithmetic_types,
|
||||
E_GL_KHX_shader_explicit_arithmetic_types_int16};
|
||||
return extensionsTurnedOn(sizeof(extensions)/sizeof(extensions[0]), extensions);
|
||||
}
|
||||
|
||||
bool TParseVersions::int8Arithmetic()
|
||||
{
|
||||
const char* const extensions[] = {
|
||||
E_GL_KHX_shader_explicit_arithmetic_types,
|
||||
E_GL_KHX_shader_explicit_arithmetic_types_int8};
|
||||
return extensionsTurnedOn(sizeof(extensions)/sizeof(extensions[0]), extensions);
|
||||
}
|
||||
|
||||
void TParseVersions::requireFloat16Arithmetic(const TSourceLoc& loc, const char* featureDesc)
|
||||
{
|
||||
const char* const extensions[] = {
|
||||
#if AMD_EXTENSIONS
|
||||
E_GL_AMD_gpu_shader_half_float,
|
||||
#endif
|
||||
E_GL_KHX_shader_explicit_arithmetic_types,
|
||||
E_GL_KHX_shader_explicit_arithmetic_types_float16};
|
||||
requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, featureDesc);
|
||||
}
|
||||
|
||||
void TParseVersions::requireInt16Arithmetic(const TSourceLoc& loc, const char* featureDesc)
|
||||
{
|
||||
const char* const extensions[] = {
|
||||
#if AMD_EXTENSIONS
|
||||
E_GL_AMD_gpu_shader_int16,
|
||||
#endif
|
||||
E_GL_KHX_shader_explicit_arithmetic_types,
|
||||
E_GL_KHX_shader_explicit_arithmetic_types_int16};
|
||||
requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, featureDesc);
|
||||
}
|
||||
|
||||
void TParseVersions::requireInt8Arithmetic(const TSourceLoc& loc, const char* featureDesc)
|
||||
{
|
||||
const char* const extensions[] = {
|
||||
E_GL_KHX_shader_explicit_arithmetic_types,
|
||||
E_GL_KHX_shader_explicit_arithmetic_types_int8};
|
||||
requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, featureDesc);
|
||||
}
|
||||
|
||||
void TParseVersions::float16ScalarVectorCheck(const TSourceLoc& loc, const char* op, bool builtIn)
|
||||
{
|
||||
if (!builtIn) {
|
||||
const char* const extensions[] = {
|
||||
#if AMD_EXTENSIONS
|
||||
E_GL_AMD_gpu_shader_half_float,
|
||||
#endif
|
||||
E_GL_EXT_shader_16bit_storage,
|
||||
E_GL_KHX_shader_explicit_arithmetic_types,
|
||||
E_GL_KHX_shader_explicit_arithmetic_types_float16};
|
||||
|
||||
#else
|
||||
const char* const extensions[2] = {E_GL_KHX_shader_explicit_arithmetic_types,
|
||||
E_GL_KHX_shader_explicit_arithmetic_types_float16};
|
||||
#endif
|
||||
requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, "explicit types");
|
||||
requireProfile(loc, ECoreProfile | ECompatibilityProfile, op);
|
||||
profileRequires(loc, ECoreProfile, 450, nullptr, op);
|
||||
profileRequires(loc, ECompatibilityProfile, 450, nullptr, op);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -844,9 +916,6 @@ void TParseVersions::explicitFloat32Check(const TSourceLoc& loc, const char* op,
|
|||
const char* const extensions[2] = {E_GL_KHX_shader_explicit_arithmetic_types,
|
||||
E_GL_KHX_shader_explicit_arithmetic_types_float32};
|
||||
requireExtensions(loc, 2, extensions, "explicit types");
|
||||
requireProfile(loc, ECoreProfile | ECompatibilityProfile, op);
|
||||
profileRequires(loc, ECoreProfile, 450, nullptr, op);
|
||||
profileRequires(loc, ECompatibilityProfile, 450, nullptr, op);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -858,8 +927,7 @@ void TParseVersions::explicitFloat64Check(const TSourceLoc& loc, const char* op,
|
|||
E_GL_KHX_shader_explicit_arithmetic_types_float64};
|
||||
requireExtensions(loc, 2, extensions, "explicit types");
|
||||
requireProfile(loc, ECoreProfile | ECompatibilityProfile, op);
|
||||
profileRequires(loc, ECoreProfile, 450, nullptr, op);
|
||||
profileRequires(loc, ECompatibilityProfile, 450, nullptr, op);
|
||||
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 400, nullptr, op);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -870,9 +938,6 @@ void TParseVersions::explicitInt8Check(const TSourceLoc& loc, const char* op, bo
|
|||
const char* const extensions[2] = {E_GL_KHX_shader_explicit_arithmetic_types,
|
||||
E_GL_KHX_shader_explicit_arithmetic_types_int8};
|
||||
requireExtensions(loc, 2, extensions, "explicit types");
|
||||
requireProfile(loc, ECoreProfile | ECompatibilityProfile, op);
|
||||
profileRequires(loc, ECoreProfile, 450, nullptr, op);
|
||||
profileRequires(loc, ECompatibilityProfile, 450, nullptr, op);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -883,8 +948,7 @@ void TParseVersions::float16OpaqueCheck(const TSourceLoc& loc, const char* op, b
|
|||
if (! builtIn) {
|
||||
requireExtensions(loc, 1, &E_GL_AMD_gpu_shader_half_float_fetch, op);
|
||||
requireProfile(loc, ECoreProfile | ECompatibilityProfile, op);
|
||||
profileRequires(loc, ECoreProfile, 450, nullptr, op);
|
||||
profileRequires(loc, ECompatibilityProfile, 450, nullptr, op);
|
||||
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 400, nullptr, op);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -893,18 +957,38 @@ void TParseVersions::float16OpaqueCheck(const TSourceLoc& loc, const char* op, b
|
|||
void TParseVersions::explicitInt16Check(const TSourceLoc& loc, const char* op, bool builtIn)
|
||||
{
|
||||
if (! builtIn) {
|
||||
const char* const extensions[] = {
|
||||
#if AMD_EXTENSIONS
|
||||
const char* const extensions[3] = {E_GL_AMD_gpu_shader_int16,
|
||||
E_GL_KHX_shader_explicit_arithmetic_types,
|
||||
E_GL_KHX_shader_explicit_arithmetic_types_int16};
|
||||
#else
|
||||
const char* const extensions[2] = {E_GL_KHX_shader_explicit_arithmetic_types,
|
||||
E_GL_KHX_shader_explicit_arithmetic_types_int16};
|
||||
E_GL_AMD_gpu_shader_int16,
|
||||
#endif
|
||||
E_GL_KHX_shader_explicit_arithmetic_types,
|
||||
E_GL_KHX_shader_explicit_arithmetic_types_int16};
|
||||
requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, "explicit types");
|
||||
}
|
||||
}
|
||||
|
||||
void TParseVersions::int16ScalarVectorCheck(const TSourceLoc& loc, const char* op, bool builtIn)
|
||||
{
|
||||
if (! builtIn) {
|
||||
const char* const extensions[] = {
|
||||
#if AMD_EXTENSIONS
|
||||
E_GL_AMD_gpu_shader_int16,
|
||||
#endif
|
||||
E_GL_EXT_shader_16bit_storage,
|
||||
E_GL_KHX_shader_explicit_arithmetic_types,
|
||||
E_GL_KHX_shader_explicit_arithmetic_types_int16};
|
||||
requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, "explicit types");
|
||||
}
|
||||
}
|
||||
|
||||
void TParseVersions::int8ScalarVectorCheck(const TSourceLoc& loc, const char* op, bool builtIn)
|
||||
{
|
||||
if (! builtIn) {
|
||||
const char* const extensions[] = {
|
||||
E_GL_EXT_shader_8bit_storage,
|
||||
E_GL_KHX_shader_explicit_arithmetic_types,
|
||||
E_GL_KHX_shader_explicit_arithmetic_types_int8};
|
||||
requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, "explicit types");
|
||||
requireProfile(loc, ECoreProfile | ECompatibilityProfile, op);
|
||||
profileRequires(loc, ECoreProfile, 450, nullptr, op);
|
||||
profileRequires(loc, ECompatibilityProfile, 450, nullptr, op);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -915,9 +999,6 @@ void TParseVersions::explicitInt32Check(const TSourceLoc& loc, const char* op, b
|
|||
const char* const extensions[2] = {E_GL_KHX_shader_explicit_arithmetic_types,
|
||||
E_GL_KHX_shader_explicit_arithmetic_types_int32};
|
||||
requireExtensions(loc, 2, extensions, "explicit types");
|
||||
requireProfile(loc, ECoreProfile | ECompatibilityProfile, op);
|
||||
profileRequires(loc, ECoreProfile, 450, nullptr, op);
|
||||
profileRequires(loc, ECompatibilityProfile, 450, nullptr, op);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -930,8 +1011,7 @@ void TParseVersions::int64Check(const TSourceLoc& loc, const char* op, bool buil
|
|||
E_GL_KHX_shader_explicit_arithmetic_types_int64};
|
||||
requireExtensions(loc, 3, extensions, "shader int64");
|
||||
requireProfile(loc, ECoreProfile | ECompatibilityProfile, op);
|
||||
profileRequires(loc, ECoreProfile, 450, nullptr, op);
|
||||
profileRequires(loc, ECompatibilityProfile, 450, nullptr, op);
|
||||
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 400, nullptr, op);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue