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

Generating functions improperly #78

Closed
ready4droid opened this issue Oct 5, 2015 · 8 comments
Closed

Generating functions improperly #78

ready4droid opened this issue Oct 5, 2015 · 8 comments

Comments

@ready4droid
Copy link

I am working on a Spir-V Decompiler and am looking at some binaries produced by glslang. It incorrectly generates opcode 54 (OpFunction) with only a 4 byte word count, followed by multiple other OpFunction opcodes. This is incorrect, because it should be immediately followed by 55, OpFunctionParameter, for each argument, and then followed by a 56 for OpFuncitonEnd. There is no generated OpFunctionParameter or OpFuncitonEnd in the created binary. Both source and binary are attached. Compiled using version 2.2.687

@ready4droid
Copy link
Author

I stand corrected, it can't attach the binary file. Here is the source:
#version 110

attribute vec2 position;

varying vec2 texcoord;

void main()
{
gl_Position = vec4(position, 0.0, 1.0);
texcoord = position * vec2(0.5) + vec2(0.5);
}

@ready4droid
Copy link
Author

After a bit more research, I realize it's not that it's generating functions improperly. The function that it is creating is really supposed to just be a name (OpName, opcode 5). So it's incorrectly generating opcodes.

Even OpExtInstImport is being generated as opcode 4 instead of opcode 11. Is there a new standard i'm missing where these things have changed?

@baldurk
Copy link
Contributor

baldurk commented Oct 5, 2015

Building from head code the binary SPIR-V seems fine for me (OpExtInstImport first word highlighted with **s):

00000000    03 02 23 07   63 00 00 00  BB 00 1A 05  41 00 00 00  00 00 00 00  ..#.c.......A.......
00000014    03 00 03 00   02 00 00 00  A4 01 00 00  11 00 02 00  01 00 00 00  ....................
00000028   *0B 00 06 00*  01 00 00 00  47 4C 53 4C  2E 73 74 64  2E 34 35 30  ........GLSL.std.450
0000003C    00 00 00 00

OpExtInstImport was opcode 4 in rev 30 of SPIR-V, but glslang generates rev 31 which is opcode 11. Maybe you're building glslang from somewhere else, or running an older binary?

@ready4droid
Copy link
Author

I downloaded the official windows executable from the https://www.khronos.org/opengles/sdk/tools/Reference-Compiler/ website. (https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang/Install). I didn't realize it was so out of date, I will update tomorrow. Thanks for the help, I thought it was something weird because they were all formed properly just that the opcode # wasn't matching up with the reference api.

@johnkslang
Copy link
Member

FYI, I updated the binaries at Khronos, but yes, they are generally updated less frequently than the source here at GitLab.

@ready4droid
Copy link
Author

ready4droid commented Oct 6, 2015 via email

@baldurk
Copy link
Contributor

baldurk commented Oct 6, 2015

There is a poll in #42 about which VS version to support, currently vs2010 would almost work but needs some minor tweaks. I have a branch that isn't up to date where I try and keep 2010 working, since that's what I need.

@ready4droid
Copy link
Author

Not a big deal, didn't realize the binary was that outdated and wasn't
having luck compiling. I got it now though. Slowly working on a software
Vulcan driver, of only the spec would be released. I mostly just copied
the mantle API until they do.
On Oct 6, 2015 4:41 PM, "Baldur Karlsson" notifications@github.com wrote:

There is a poll in #42 #42
about which VS version to support, currently vs2010 would almost work but
needs some minor tweaks. I have a branch that isn't up to date where I try
and keep 2010 working, since that's what I need.


Reply to this email directly or view it on GitHub
#78 (comment)
.

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

No branches or pull requests

3 participants