-
Notifications
You must be signed in to change notification settings - Fork 326
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
More fixes for specific sample apk. #1166
Changes from all commits
f944771
7d66c66
99ab27f
83f2be2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -454,7 +454,10 @@ func compat(ctx context.Context, device *device.Instance) (transform.Transformer | |
if err != nil { | ||
log.W(ctx, "%v compat: %v", cmd, err) | ||
} | ||
opts := shadertools.Option{ShaderType: st} | ||
opts := shadertools.Options{ | ||
ShaderType: st, | ||
Relaxed: true, // find_issues will still report bad GLSL. | ||
} | ||
|
||
// Trim any prefix whitespace / newlines. | ||
// This isn't legal if it comes before the #version, but this | ||
|
@@ -598,12 +601,19 @@ func compat(ctx context.Context, device *device.Instance) (transform.Transformer | |
return | ||
} | ||
case *GlTexStorage2DMultisample: | ||
{ | ||
if version.IsES || version.AtLeastGL(4, 3) { | ||
// glTexStorage2DMultisample is supported by replay device. | ||
cmd := *cmd | ||
textureCompat.convertFormat(ctx, cmd.Target, &cmd.Internalformat, nil, nil, out, id, &cmd) | ||
out.MutateAndWrite(ctx, id, &cmd) | ||
return | ||
} else { | ||
// glTexStorage2DMultisample is not supported by replay device. | ||
// Use glTexImage2DMultisample instead. | ||
cmd := cb.GlTexImage2DMultisample(cmd.Target, cmd.Samples, cmd.Internalformat, cmd.Width, cmd.Height, cmd.Fixedsamplelocations) | ||
textureCompat.convertFormat(ctx, cmd.Target, &cmd.Internalformat, nil, nil, out, id, cmd) | ||
out.MutateAndWrite(ctx, id, cmd) | ||
} | ||
return | ||
case *GlTexStorage3D: | ||
{ | ||
cmd := *cmd | ||
|
@@ -905,13 +915,17 @@ func compat(ctx context.Context, device *device.Instance) (transform.Transformer | |
// It has no effect on rendering so just drop it. | ||
return | ||
|
||
case *GlInvalidateFramebuffer, | ||
*GlDiscardFramebufferEXT: // GL_EXT_discard_framebuffer | ||
case *GlDiscardFramebufferEXT: // GL_EXT_discard_framebuffer | ||
// It may not be implemented by the replay driver. | ||
// It is only a hint so we can just drop it. | ||
// TODO: It has performance impact so we should not ignore it when profiling. | ||
return | ||
|
||
case *GlInvalidateFramebuffer, *GlInvalidateSubFramebuffer: | ||
if !version.AtLeastES(3, 0) || !version.AtLeastGL(4, 3) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, I would prefer unconditional. You might disagree. |
||
return // Not supported. Only a hint. Drop it. | ||
} | ||
|
||
case *GlMapBufferOES: | ||
if !version.IsES { // Remove extension suffix on desktop. | ||
cmd := cb.GlMapBuffer(cmd.Target, cmd.Access, memory.Pointer(cmd.Result)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,11 +130,11 @@ void set_error_msg(code_with_debug_info_t* x, std::string msg) { | |
strcpy(x->message, msg.c_str()); | ||
} | ||
|
||
std::vector<unsigned int> parseGlslang(const char* code, std::string* err_msg, | ||
shader_type type, bool es_profile) { | ||
std::vector<unsigned int> parseGlslang(const char* code, const char* preamble, | ||
std::string* err_msg, shader_type type, bool es_profile, bool relaxed_errs) { | ||
std::vector<unsigned int> spirv; | ||
|
||
EShMessages messages = EShMsgDefault; | ||
EShMessages messages = relaxed_errs ? EShMsgRelaxedErrors : EShMsgDefault; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, glslang has native support for relaxed compilation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah - I spent a while trying to hack away, then found this. Happy days. |
||
EShLanguage lang = EShLangVertex; | ||
switch (type) { | ||
case VERTEX: { lang = EShLangVertex; break; } | ||
|
@@ -147,6 +147,7 @@ std::vector<unsigned int> parseGlslang(const char* code, std::string* err_msg, | |
|
||
glslang::InitializeProcess(); | ||
glslang::TShader shader(lang); | ||
shader.setPreamble(preamble); | ||
shader.setStrings(&code, 1); | ||
// use 100 for ES environment, 330 for desktop | ||
int default_version = es_profile ? 100 : 330; | ||
|
@@ -186,7 +187,8 @@ code_with_debug_info_t* convertGlsl(const char* input, size_t length, const opti | |
code_with_debug_info_t* result = new code_with_debug_info_t{}; | ||
std::string err_msg; | ||
|
||
std::vector<unsigned int> spirv = parseGlslang(input, &err_msg, options->shader_type, true); | ||
std::vector<unsigned int> spirv = parseGlslang( | ||
input, options->preamble, &err_msg, options->shader_type, true, options->relaxed); | ||
|
||
if (!err_msg.empty()) { | ||
set_error_msg(result, "Failed to parse original source code:\n" + err_msg); | ||
|
@@ -239,7 +241,7 @@ code_with_debug_info_t* convertGlsl(const char* input, size_t length, const opti | |
|
||
// check if changed source code compiles again | ||
if (options->check_after_changes) { | ||
parseGlslang(result->source_code, &err_msg, options->shader_type, false); | ||
parseGlslang(result->source_code, nullptr, &err_msg, options->shader_type, false, false); | ||
} | ||
|
||
if (!err_msg.empty()) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would drop the 4.3 part of the condition. But that is probably just me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to steer the compat code towards doing the right checks. My longer term plan of action is to pull this logic out of this mega function and as methods of the command. We can then use these methods check to see if the particular command is supported by the given device - and use this to pick the most suitable device and/or show compatibility warnings in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with regard to checks - but in different way - ideally add some support for desktop GL into the api files as well, and then mutate the output through that to verify it should work. For a set of devices this would tell us which would fail (and how), and which would pass, all without trying to run it on the devices. As a poor man's version of this you could just record the minimal requirements as you execute the compat. So even without any replay device you would get transformed stream and the needed min spec.
With regards transforms - I prefer unconditional ones. That is, simplify complicated GL commands to simpler canonical ones. This is great example of that. There is no reason not to always simplify to more supported glTexImage2DMultisample version. Similarly all other *Storage methods can be simplified to more supported GL commands (although that is a bit more code, and we did not hit that compat need yet).
Anyway, it just my 1 cent. Feel free to follow your path. But if you get to situation where you can not reproduce a bug because the user's GL version and set of extensions follows a different path then yours, don't say I didn't warn you :-P (e.g. if the AtLeast(4,3) part of this block gets accidentally broken in the future as part of refactoring, you will never find out on your machine)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acknowledged.