Added HLSL shader for descriptor indexing sample
This commit is contained in:
parent
a86bdc2c44
commit
ad447e10c4
7 changed files with 54 additions and 0 deletions
|
|
@ -1,3 +1,5 @@
|
|||
// Copyright 2021 Sascha Willems
|
||||
|
||||
#version 450
|
||||
|
||||
#extension GL_EXT_nonuniform_qualifier : require
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
// Copyright 2021 Sascha Willems
|
||||
|
||||
#version 450
|
||||
|
||||
layout (location = 0) in vec3 inPos;
|
||||
|
|
|
|||
|
|
@ -64,5 +64,6 @@ for root, dirs, files in os.walk(dir_path):
|
|||
'-fspv-extension=SPV_NV_ray_tracing',
|
||||
'-fspv-extension=SPV_KHR_multiview',
|
||||
'-fspv-extension=SPV_KHR_shader_draw_parameters',
|
||||
'-fspv-extension=SPV_EXT_descriptor_indexing',
|
||||
hlsl_file,
|
||||
'-Fo', spv_out])
|
||||
|
|
|
|||
17
data/shaders/hlsl/descriptorindexing/descriptorindexing.frag
Normal file
17
data/shaders/hlsl/descriptorindexing/descriptorindexing.frag
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright 2021 Sascha Willems
|
||||
// Non-uniform access is enabled at compile time via SPV_EXT_descriptor_indexing (see compile.py)
|
||||
|
||||
Texture2D textures[] : register(t1);
|
||||
SamplerState samplerColorMap : register(s1);
|
||||
|
||||
struct VSOutput
|
||||
{
|
||||
float4 Pos : SV_POSITION;
|
||||
[[vk::location(0)]] int TextureIndex : TEXTUREINDEX0;
|
||||
[[vk::location(1)]] float2 UV : TEXCOORD0;
|
||||
};
|
||||
|
||||
float4 main(VSOutput input) : SV_TARGET
|
||||
{
|
||||
return textures[NonUniformResourceIndex(input.TextureIndex)].Sample(samplerColorMap, input.UV);
|
||||
}
|
||||
BIN
data/shaders/hlsl/descriptorindexing/descriptorindexing.frag.spv
Normal file
BIN
data/shaders/hlsl/descriptorindexing/descriptorindexing.frag.spv
Normal file
Binary file not shown.
32
data/shaders/hlsl/descriptorindexing/descriptorindexing.vert
Normal file
32
data/shaders/hlsl/descriptorindexing/descriptorindexing.vert
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright 2021 Sascha Willems
|
||||
|
||||
struct VSInput
|
||||
{
|
||||
[[vk::location(0)]] float3 Pos : POSITION0;
|
||||
[[vk::location(1)]] float2 UV : TEXCOORD0;
|
||||
[[vk::location(2)]] int TextureIndex : TEXTUREINDEX0;
|
||||
};
|
||||
|
||||
struct Matrices {
|
||||
float4x4 projection;
|
||||
float4x4 view;
|
||||
float4x4 model;
|
||||
};
|
||||
|
||||
cbuffer matrices : register(b0) { Matrices matrices; };
|
||||
|
||||
struct VSOutput
|
||||
{
|
||||
float4 Pos : SV_POSITION;
|
||||
[[vk::location(0)]] int TextureIndex : TEXTUREINDEX0;
|
||||
[[vk::location(1)]] float2 UV : TEXCOORD0;
|
||||
};
|
||||
|
||||
VSOutput main(VSInput input)
|
||||
{
|
||||
VSOutput output = (VSOutput)0;
|
||||
output.UV = input.UV;
|
||||
output.TextureIndex = input.TextureIndex;
|
||||
output.Pos = mul(matrices.projection, mul(matrices.view, mul(matrices.model, float4(input.Pos.xyz, 1.0))));
|
||||
return output;
|
||||
}
|
||||
BIN
data/shaders/hlsl/descriptorindexing/descriptorindexing.vert.spv
Normal file
BIN
data/shaders/hlsl/descriptorindexing/descriptorindexing.vert.spv
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue