Загрузка...

How can I solve "syntax error, unexpected SAMPLER, expecting RIGHT_PAREN" when compiling Vulkan GLS

Hello everyone! I hope this video has helped solve your questions and issues. This video is shared because a solution has been found for the question/problem. I create videos for questions that have solutions. If you have any other issues, feel free to reach out to me on Instagram: https://www.instagram.com/ky.emrah

Below, you can find the text related to the question/problem. In the video, the question will be presented first, followed by the answers. If the video moves too fast, feel free to pause and review the answers. If you need more detailed information, you can find the necessary sources and links at the bottom of this description. I hope this video has been helpful, and even if it doesn't directly solve your problem, it will guide you to the source of the solution. I'd appreciate it if you like the video and subscribe to my channel!How can I solve "syntax error, unexpected SAMPLER, expecting RIGHT_PAREN" when compiling Vulkan GLSL shader with sampler2D used as function argument?

I'm playing around with Qt's QRhi and more specifically its QtShaderTools and the qsb shader compiler tool.
Basically it takes a Vulkan-GLSL shader source, and transforms it into SPIR-V and any other shader source/bytecode supported by QRhi.
There's then some C++-side API to facilitate loading the generated files and run the shaders on the actual backend API (be it OpenGL, Vulkan, DX, Metal, and whatnot).
qsb
I'm trying to get a small bit of render code to work in a much larger project that uses OpenGL 3.3 Core extensively (through QOpenGL). I'm setting up the shader compilation and converting our #version 330 GLSL shader code to Vulkan GLSL #version 460.
#version 330
#version 460
The shader in question defines a helper function with a sampler2D as argument:
sampler2D
vec4 sampleFt( in sampler2D sampler, vec2 coordSource )
{ ... }

vec4 sampleFt( in sampler2D sampler, vec2 coordSource )
{ ... }

Compiling this shader with Qt's qsb tool throws an error pointing to this line:
qsb
QSpirvCompiler: Failed to parse shader
Shader baking failed: ERROR: file : line : '' : syntax error, unexpected SAMPLER, expecting RIGHT_PAREN

QSpirvCompiler: Failed to parse shader
Shader baking failed: ERROR: file : line : '' : syntax error, unexpected SAMPLER, expecting RIGHT_PAREN

I find lots of examples online of Vulkan GLSL shaders passing sampler2D as function arguments, and can't seem to find how I need to change this to make it work.
sampler2D
As an aside: our shaders are basically concatenated snippets of glsl, where this helper function is in a separate (and reused) source file from the actual calling code in a void main() defined in various other source files. The sampler in question is "passed to" the shader as a uniform, so removing the argument and using the uniform name could be made to work, but that seems to preclude any type of code having more than one sampler2D and calling the above helper function with both, so I think I'm missing something obvious.
void main()
uniform
Tags: glsl,shader,vulkan,spir-v,qrhiSource of the question:
https://stackoverflow.com/questions/79042975

Question and source license information:
https://meta.stackexchange.com/help/licensing
https://stackoverflow.com/

Видео How can I solve "syntax error, unexpected SAMPLER, expecting RIGHT_PAREN" when compiling Vulkan GLS канала Emrah KAYA
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять