I'm modifying a HLSL shader used in D3D12 to compile to SPIR-V because I want to use the same shader code in Vulkan. Here's the shader:
#if !VULKAN
#define layout(a)
#else
#define register(a) blank
#endif
struct VSOutput
{
float4 pos : SV_Position;
float2 uv : TEXCOORD;
float4 color : COLOR;
};
layout(binding=1) Texture2D<float4> tex : register(t0);
layout(binding=1) SamplerState sLinear : register(s0);
float4 main( VSOutput vsOut ) : SV_Target
{
return tex.SampleLevel( sLinear, vsOut.uv, 0 ) * vsOut.color;
};
Can I use the same binding for both texture and sampler if my descriptor set at index 1 has type VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
or must I use two binding slots, one for the texture and one for the sampler? I'm asking because my pipeline creation fails with error
Vulkan warning: [ParameterValidation], code: 9: vkCreateGraphicsPipelines: returned VK_ERROR_INITIALIZATION_FAILED, indicating that initialization of an object has failed
if using this shader instead of a GLSL shader compiled into SPIR-V. My GLSL shader uses the texture like this:
layout (binding = 1) uniform sampler2D textureMap;