Comments (16)
As suggested in the original post, one horrible solution is to use GL_EXT_shader_image_load_formatted, then run your script through glslangValidator
to convert it to SPV, then run spirv-opt
with --inline-entry-points-exhaustive
, which inlines everything. Then either load the SPV in vulkan or opengl (if implementation supports it) or, alternatively, use spirv-cross
to convert it back to glsl, and then load it as normal. I've gotten most of such a pipeline working, though I can't say it will work for everyone or on all hardware. I also was simultaneously doing other horrible hacks, so take this all with a grain of salt until you try it and it works in all contexts.
from glsl.
Adding +1, it's been five years and it's still not possible to pass images around to functions.
from glsl.
Just adding my +1 here. This seems like a very serious functionality gap in the language.
from glsl.
Was a resolution reached for this? It's been four years and being able to pass a storage image to a function would make my code so much better
from glsl.
in vulkan 1.1.121.2 this code:
layout(binding = 0, r32f) uniform image2D testImage;
float Func(image2D image)
{
return imageLoad(image, ivec2(0, 0)).r;
}
void main()
{
float test = Func(testImage);
}
gives this error:
'format' : image formats must match
Why is it happening? Is there a workaround to pass image2D argument to a function?
from glsl.
Why is it happening? Is there a workaround to pass image2D argument to a function?
There is no way, it's mostly hardware limitation.
How is this sort of thing a hardware limitation, when - at least my understanding is - everything is basically inlined before being executed on the hardware, and if you manually inline this, it is valid?
from glsl.
Has there been any progress on this? I'm running into this exact issue today.
from glsl.
It seems like we should allow format qualifiers on function parameters, so that loads can be supported.
I think that's the right answer, and possibly to warn (or error) at the GLSL level if the argument type does not match the parameter type, including the format.
See KhronosGroup/glslang#1720 for a recent complaint about this.
from glsl.
We discussed on the call today that there was a very old bug (11466) about this issue. My recollection was that the driver was supposed to do whatever specialization of functions was necessary to make it work. Since most functions would be inlined, this would be trivial. It seems like the version of the shader with just g()
should just work. SPIR-V makes things a bit more complicated.
from glsl.
On AMD, the example compute shader above compiles with no errors.
from glsl.
FWIW, the original issue was reported to me by an internal Vulkan developer. We should definitely answer the question for both GL and Vulkan, and as Ian says it is probably harder with SPIR-V.
from glsl.
Since we can't bugfix the current GLSL/ESSL specs for this, I think we need an extension so applications that want to use format qualifiers on function parameters know that it's supported by the implementation. If that makes sense we need a volunteer to create the extension.
from glsl.
Glslang is updated now to give an error if formats do not match between calling argument and formal parameter (unless the formal parameter is writeonly and at least one of caller/callee has an unknown format).
from glsl.
I saw a whole bunch of changes and discussions around this topic as it keeps popping up for the past 3 years whenever anybody attempts to pass a readwrite texture into a function. Is there any way (even a workaround) to do this as of today?
from glsl.
I changed my mind about that question. I suppose that is language and/or compiler problem. At least, for Vulkan API, due SPIR-V. About OpenGL or OpenGL ES, I currently have no idea...
from glsl.
+1
from glsl.
Related Issues (20)
- Support for Vertex/Fragment layout blocks
- Is GLSL had some online document? HOT 2
- Khronos GLSL grammar 4.60.7 has missing parameter-type for "P" in "textureGrad" HOT 2
- GLSL grammar allows for statements like "float;" but does not say they're invalid HOT 1
- GL_KHR_cooperative_matrix.txt not public HOT 1
- Vulkan reserved keywords are missing from the GLSL ES 3.2 Spec HOT 1
- GLSL Specification 4.60.8: incorrect formatting HOT 1
- halfBitsToUInt16 is missing HOT 4
- GL_EXT_shader_explicit_arithmetic_types misspelling of halfBitsToUInt16?
- GL_KHR_vulkan_glsl allows gl_VertexIndex in any stage
- [GLSL 4.6 Specification] Clarify the translation from UTF-8 scalar values to the corresponding character set tokens HOT 3
- Clarify GLSL for-loop scoping rules HOT 2
- GLSL_NV_mesh_shader.txt lacks a figure (figure 3.1)
- Clarify compilation of unbound array
- Description of texelFetch erroneously implies the lod parameter can be omitted HOT 1
- Variables of opaque types should be allowed
- Argument variable using out keyword causes unexpected behaviour
- Using a specialization constant as a size of an array placed inside a buffer results in a runtime error
- local workgroup specification while selecting alternative entrypoint HOT 3
- "&=" in the docs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from glsl.