Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Yaoi Gagarin
Feb 20, 2014

giogadi posted:

I'm following vulkan-tutorial.com on an old mac with integrated graphics. I ran into a weird issue, and I wonder if any of y'all have a clue about what could be going on.

The first part of the tutorial involves drawing a single triangle to the screen without using a vertex buffer at all, so the vertex shader just hardcodes the vertex positions and colors into the shader, using gl_VertexIndex to select the appropriate position/color. I'm following the code exactly to the tutorial, but my triangle's colors are wrong: only one corner is red, and the other two corners are black.

code:
// Vertex shader
#version 450

layout(location = 0) out vec3 vertColor;

vec2 positions[3] = vec2[](
     vec2(0.0, -0.5),    
     vec2(0.5, 0.5),
     vec2(-0.5, 0.5)
);

vec3 colors[3] = vec3[](
     vec3(1.0, 0.0, 0.0),
     vec3(0.0, 1.0, 0.0),
     vec3(0.0, 0.0, 1.0)
);

void main() {
     gl_Position = vec4(positions[gl_VertexIndex], 0.0, 1.0);
     vertColor = colors[gl_VertexIndex];
}
The fragment shader is super simple, but including it just for completeness:

code:
// fragment shader
#version 450

layout(location = 0) in vec3 vertColor;

layout(location = 0) out vec4 outColor;

void main() {
     outColor = vec4(vertColor, 1.0);
}
HOWEVER, here's the weird part: if I change main to re-set the values of the colors array individually, the result looks perfectly fine:

code:
// <above main, all the code is the same>
void main() {
     gl_Position = vec4(positions[gl_VertexIndex], 0.0, 1.0);

     colors[0] = vec3(1.0, 0.0, 0.0);
     colors[1] = vec3(0.0, 1.0, 0.0);
     colors[2] = vec3(0.0, 0.0, 1.0);
     vertColor = colors[gl_VertexIndex];
}
Does anyone have any idea why the 2nd main() function would work where the 1st one didn't? There seems to be something odd about the array of vec3's. But the weird thing is that the array of vec2's before that for the positions works just fine.

e: I realize that this specific shader is totally unrealistic, but I'm stuck on this because in the future if I want to use hardcoded constant arrays for some reason, I'm not gonna trust 'em if they can exhibit weird behavior I don't understand!!!


This could very well be a compiler bug. Can you post the SPIR-V? The Vulkan sdk has a program called spirv-dis you can use to get a text listing of a SPIR-V binary. I'm not familiar with Mac development but I assume you're using glslang to convert from GLSL to SPIR-V right?


Ranzear posted:

Suppose I have a compute shader with a really sparse SSBO array that is ostensibly a tree structure that fills itself up (fixed depth, fixed size). Is it fine to just no-op any indexes that haven't been populated yet?

Edit: Found better leverage of my acceleration structure to still do everything parallel but get 90% of the benefit. Still posing the question whether a single if-then-no-op is potentially slow just because it needs to split the execution weirdly or something.

If you mean something like:


code:

if (is_populated[threadID]) {
  // Do stuff
}

It'll really depend on how much work is done on that branch. If it's really quick then it's probably not a big deal but if it's long then you could be hurting your utilization over time.

Note that if you have an else branch on that it gets even worse because all the threads in each warp will have to run both if even one is different

Adbot
ADBOT LOVES YOU

Yaoi Gagarin
Feb 20, 2014

giogadi posted:

A little while back I actually found a github issue on MoltenVK with my exact problem:

https://github.com/KhronosGroup/MoltenVK/issues/1499

It looks like it's a bug in Intel's Metal drivers. I've been meaning to put together a super minimal example in pure Metal that reproduces the issue that I can send over to Apple.

It really sucks that bugs like this exist - it makes me afraid to use any graphics API built on top of Metal because it could potentially have weird bugs like the above. It's shameful that support for intel-based macs is so bad - there are still soooo many of these macbooks out there that otherwise work really great!

Tbf any API might have bugs, that's just the nature of software. I've seen stuff like this in OpenGL too.

Yaoi Gagarin
Feb 20, 2014

Has anyone here actually used mesh shaders in production? Did you have a problem for which you felt they were the best option?

I'm curious because they've been around a while and the only game I've heard uses them is Alan Wake 2

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply