So apparently tex2D is still supported in HLSL shaderModel 6.0 so why does doing something like the following produce validation errors:
float myFloat = tex2D(MySampler, In.texCoord).w;
It does not like tex2D, if I make a Texture2D MyTex variable 1st then do
MyFloat = MyTex.Sample(MySampler, In.texCoord).w; validation is fine.
Of course I have disables validation with /Vd and dxc spits out a compiled file but no .asm when specified, dxc also tends to jam up with tex2D usage....
I have tried compilation with multiple versions of dxc.exe
Any ideas?
Thanks
Related
I am currently writing a Shader class, and was curious whether following use case in opengl is valid.
Suppose you added source code (SourceCode) to a shader (specified by handle):
void glShaderSource(handle, 1, sourceCode, nullptr);
Then you try to compile the shader and it fails.
Is it a valid and/or well tested use case to update sourceCode, call glShaderSource again as above, and recompile?
Sure, you can compile other shaders after one failed.
well tested use case
I'm sure it's tested, but nobody does this. Fix your shader before you even start your program, not after.
When compiling shaders with OpenGL, you can retrieve log lines by calling glGetShaderInfoLog. At least in the driver I'm using (Nvidia), this will return results like:
0(14) : error C1035: assignment of incompatible types
The leading 0 is the index of the string passed to glShaderSource and the number in parentheses is the line number.
Can I set that value to the actual filename so the compiler errors are more useful? Alternatively, is there a consistent way to parse the driver output?
I'm trying to use two opengl images, one of which is sparse and the other used as a sort of page table, in which I keep track of the page actually commited.
I have a simple little shader, which looks like this (main not included):
#version 450 core
#extension GL_ARB_shader_image_load_store : require
uniform float gridSize;
uniform float pageTableSize;
bool isPageInMemoryOrRequest (in ivec3 pos)
{
bool returnValue = false;
if ( 255u == imageAtomicExchange(pageTable, pos, 128u) )
{
returnValue = true;
}
return returnValue;
}
And my problem is that this won't compile. I keep getting this message:
Error C1115: unable to find compatible overloaded function "imageAtomicExchange(struct uimage3D1x8_bindless, ivec3, uint)"
I'm pretty sure I've never seen that _bindless part anywhere in the specs and I'm not exactly sure how the compiler figures out that is a bindless texture at compile time (or maybe they're all bindless in the latest drivers).
I've got a GTX660TI and I'm using the 352.86 drivers.
I'm wondering if anyone's had this sort of issue before and could tell me what might the problem be.
Thanks in advance.
According to the extension specification of ARB_shader_image_load_store (Section 8.X, Image Functions), there is only of very limited number of supported formats for atomic operations:
Atomic memory operations
are supported on only a subset of all image variable types; must
be either:
an image variable with signed integer components (iimage*) and a
format qualifier of "r32i", or
an image variable with unsigned integer components (uimage*) and a
format qualifier of "r32ui".
I assume from the error message, that you have tried to use a r8ui format, which is not supported.
I have a compiled shader or program (not sure of the correct term) and I need to delete it.
How do I find the Id of compiled programs and/or shaders to do so?
I know it exists because the debugger tells me that I am trying to redefine it, and cannot compile it again because of this:
ERROR: 0:1: error(#198) Redefinition at_coord_Y
ERROR: 1:1: error(#248) Function already has a body main
The first line of the shaders source is:
"in float at_coord_Y;"
Can I somehow use this to find the Id?
EDIT 1: Hopefully to clarify a bit, the shader fails to compile because it already exists.
GLint compiled = UNDEFINED_VALUE;
const GLchar* shaderSrc[] = {
"in float at_coord_Y;",
"void main()",
"{",
// Dont mind the empty space
"}"
};
GLuint shaderId = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(shaderId, glNumberOfLines(shaderSrc), shaderSrc, NULL);
glCompileShader(shaderId); // Fail to compile because it already exists. Redefinition error.
glGetShaderiv(shaderId), GL_COMPILE_STATUS, &compiled); // Compile status GL_FALSE
But how can I find the Id of an existing shader (or program)?
You are completely misunderstanding the error. OpenGL isn't saying that the shader object (what you get with glCreateShader) is already defined. It's saying that there is a problem in your shader's text (what you passed with glShaderSource).
There are many problems with your shader loading. I have no idea where you got this loading code from, but I strongly advise avoiding that place.
glShaderSource takes multiple strings, yes. But that doesn't mean you throw every line into a separate string. It's supposed to be used for "headers" and the like. Which means that the compiler will concatenate all of the strings together when compiling them.
In general, unless you're using the extra strings as headers to prefix onto your main shader, just pass an array of one string. Save yourself the pain.
Also, you didn't use a #version directive. Without specifying a version, you're forced to use GLSL 1.10. And in GLSL 1.10, in float at_coord_Y; is not a legal definition.
I'm using OpenGL 3.3 on a GeForce 9800 GTX. The reference pages for 3.3 say that an invalid operation with glBindFramebuffer indicates a framebuffer ID that was not returned from glGenFramebuffers. Yet, I output the ID returned by glGenFramebuffers and the ID I send later to glBindFramebuffer and they are the same.
The GL error goes away, however, when I change the target parameter in glBindFramebuffer from GL_DRAW_FRAMEBUFFER to GL_FRAMEBUFFER. The documentation says I should be able to use GL_DRAW_FRAMEBUFFER. Is there any case in which you can't bind to GL_DRAW_FRAMEBUFFER? Is there any harm from using GL_FRAMEBUFFER instead of GL_DRAW_FRAMEBUFFER? Is this a symptom of a larger problem?
If glBindFramebuffer(GL_FRAMEBUFFER) works when glBindFramebuffer(GL_DRAW_FRAMEBUFFER) does not, and we're not talking about the EXT version of these functions and enums (note the lack of "EXT" suffixes), then it's likely that you may have done something wrong. GL_INVALID_OPERATION is the error you get when multiple combinations of parameters that depend on different state are in conflict. If it were just a missing enum, you should get GL_INVALID_ENUM.
Of course, it could just be a driver bug too. But there's no way to know without knowing what your code looks like.