Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ARB_gpu_shader_fp64 #1998

Merged
merged 2 commits into from
Jan 8, 2020

Conversation

ShchchowAMD
Copy link
Contributor

GLSL Version : >= 150

Purpose:
Allow users to use features by enabling this extension, even in low versions.

Extension Name:
ARB_gpu_shader_fp64

Builtin-variables:
Nah

Builtin-functions:
functions overloaded for this extension, please check registry in reference.

Keywords:
Double

Features:
add support for type "double", also related functions/builtin functions
overloaded for DOUBLE. "double vector" input should be in
ARB_vertex_attrib_64bit

Reference:
https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_gpu_shader_fp64.txt

@ShchchowAMD ShchchowAMD marked this pull request as ready for review November 26, 2019 16:49
@@ -1751,7 +1751,7 @@ type_specifier_nonarray
}
GLSLANG_WEB_EXCLUDE_ON
| DOUBLE {
parseContext.doubleCheck($1.loc, "double");
parseContext.doubleCheck($1.loc, "double", parseContext.symbolTable.atBuiltInLevel());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is adding an argument necessary? parseContext already has symbolTable, so it can check itself.

That is, it seems there is not much use now for the form that does not check atBuiltInLevel so, just leave all the calls the same, and only update the function. (Or, add a parseContext.doubleCheck() that checks the builtInLevel.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi john,
The reason for this modification is that:

  1. initialization (built-in functions and variables) happens before we update extensions status in state machine.
  2. when I remove this builtin level check, glslang would report an error because it would treat "double" as an unavailable symbol in low versions during initialization when meets some overloaded functions with type "double".
  3. if we add an builtin level check here:
    3.1 initialization process would be okay as "doublecheck()" now knows they are overloaded functions.
    3.2 users, still, can only use high core version or enabling extension if they need to use fp64.

For your suggestion, do you mean that I should add another doubleCheck() for builtinLevel symbols and keep calls same in .y file? Or maybe, try to do the builtinLevel check within doubleCheck()?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to do the builtinLevel check within doubleCheck()?

Yes. Does that work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I tried before I committed in this version.

As if we put a breakpoint here, in doubleCheck(), we could know that: when a "double" symbol comes in, we have no extra information to know whether it is a built-in. We could also see that other check functions also use builtin flag to check types.

For built-in variables or functions, doubleCheck() is a part of initializing symbol table, we can't find that flag in context here as we have no context member variables. Otherwise, we still need to change doubleCheck's interface, or add context status, till here by other parameters.

I think for many types, like float16, their check functions already get this builtin flag with a default input parameter, may I know what suggestions for this part?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this adds this extra Boolean parameter to almost all (all?) calls to doubleCheck(), but with a query to the same object the method is in, so the method could more directly do the query itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, this Boolean parameter has been removed. Built-in check has been moved when call this object. There's no difference in generated test results for latest commit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to get one copy of the test instead of N copies.


if (profile != EEsProfile) {
if (profile != EEsProfile && version >= 150) { // ARB_gpu_shader_fp64
commonBuiltins.append(
"double fma(double, double, double);"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the impacts to overloaded function resolution under implicit type conversion? Version 400 has different rules than versions before 400.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll test for this and record here soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reminding, implicit converting meets errors. I'll fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnkslang Hi, John. I made some tests and find the difference is inside findFunction120 and findFunction400. Should "best match" rules be enabled in version 120-330 if I turned on type "double" with this commit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, I allow glslang to use findFunction400 when we turn on this extension, as type 'double' could be introduced with this extension.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that might be best, especially if formalized. Someone could change their shader behavior of unrelated code, just by enabling the extension, but if it's well specified that's how it works, it may be the best path.

GLSL Version : >= 150

Purpose:
Allow users to use features by enabling this extension, even in low versions.

Extension Name:
ARB_gpu_shader_fp64

Builtin-variables:
Nah

Builtin-functions:
functions overloaded for this extension, please check registry in reference.

Keywords:
Double

Features:
add support for type "double"

Reference:
https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_gpu_shader_fp64.txt

Add support for implicit conversion

1. Remove builtin double vertex (this is introduced by vertex_attrib_64bit
2. Add extension check and implicit conversion as double has been introduced
3. Add test results.
@@ -6091,7 +6091,7 @@ const TFunction* TParseContext::findFunction(const TSourceLoc& loc, const TFunct
if (isEsProfile() || version < 120)
function = findFunctionExact(loc, call, builtIn);
else if (version < 400)
function = findFunction120(loc, call, builtIn);
function = extensionTurnedOn(E_GL_ARB_gpu_shader_fp64) ? findFunction400(loc, call, builtIn) : findFunction120(loc, call, builtIn);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnkslang FYI, now when this extension turns on, we will use rules based on version 400.

I think the reason is we may still wanna remain the difference between old versions and versions larger than 400. And keep the change as small as possible (rules inside findFunction400 may be modified in the future).

When type "double" is introduced, a best match check would be enabled to allow extra implicit conversion, that's when those three rules work, to decide a best candidate.

When this extension is enabled, we have type "float", "int" and "double", same with version >= 400, which make no difference with what we do in latest version.

FYI, move builtin check to type symbol check.
Avoid modifying interface doubleCheck().
@johnkslang johnkslang merged commit 5181367 into KhronosGroup:master Jan 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants