weird problem will cullface

i am using the following vertex shader to draw a simple white screen quad:
http://pastebin.com/REr93zKP

i have set “frontFace” in my pipeline raster state to “VK_FRONT_FACE_COUNTER_CLOCKWISE”

when i set “cullMode” of the raster state to “VK_CULL_MODE_BACK_BIT”,
i just get the clear color of the image displayed.

but if i change “cullMode” to “VK_CULL_MODE_FRONT_BIT” or “VK_CULL_MODE_NONE” i get my white screen quad.

am i missing something or is this a bug ?

i am using vulkan 1.0.3.1 and nvidia driver 356.39 on Windows 10 with a 980Ti

ok it appears that the problem was that vulkan is using a different formula for figuring out the front face than gl or dx

Hello, denwan!

What do you mean “different formula” in Vulkan? I have the same problem here.
The “same” code is working on OpenGL, but not in Vulkan.

The vertexes (quad) are been rendering on right-hand rule.

	const std::vector<Vertex> vertices = { 
		{ {-0.5f, -0.5f} }, 
		{ { 0.5f, -0.5f} }, 
		{ { 0.5f,  0.5f} }, 
		{ {-0.5f,  0.5f} } 
	};
	const std::vector<uint16_t> indices = { 0, 1, 2, 2, 3, 0 };

Could you give me a hand?

The winding and cull rules in Vulkan are the same as in OpenGL. The difference is that the viewport origin is at the top-left rather than at the bottom-left. This means that the triangle ({-0.5f, -0.5f}, { 0.5f, -0.5f}, { 0.5f, 0.5f}) is top-left, top-right, bottom-right if rasterized directly to the viewport and is therefore back-facing with counter-clockwise winding.
There are multiple ways to solve this, in Vulkan 1.1 or with VK_KHR_maintenance1 you can use a negative viewport height to get the same output as OpenGL. For 3D you can invert the sign for y in the projection matrix. Or you use the DirectX way, which also has the origin at the top-left but uses clockwise winding order by default.

Regards

virtual_storm,

Now, it is clear. thank you a lot.