allow unbounded descriptor tables
This commit is contained in:
parent
9de72dceba
commit
92258b6f3e
@ -1,18 +1,23 @@
|
|||||||
#include "sh/sh_common.h"
|
#include "sh/sh_common.h"
|
||||||
|
|
||||||
#define DECL(t, n) t n : n
|
|
||||||
|
|
||||||
#define PI 3.14159265359
|
#define PI 3.14159265359
|
||||||
#define GOLDEN 1.61803398875
|
#define GOLDEN 1.61803398875
|
||||||
|
|
||||||
|
#define DECL(t, n) t n : n
|
||||||
|
#define NURI(i) NonUniformResourceIndex(i)
|
||||||
|
|
||||||
|
#if !SH_CPU
|
||||||
|
# define INLINE
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Linear color from normalized sRGB */
|
/* Linear color from normalized sRGB */
|
||||||
float4 linear_from_srgb(float4 srgb)
|
INLINE float4 linear_from_srgb(float4 srgb)
|
||||||
{
|
{
|
||||||
return float4(pow(srgb.rgb, 2.2), srgb.a);
|
return float4(pow(srgb.rgb, 2.2), srgb.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Linear color from R8G8B8A8 sRGB */
|
/* Linear color from R8G8B8A8 sRGB */
|
||||||
float4 linear_from_srgb32(uint srgb32)
|
INLINE float4 linear_from_srgb32(uint srgb32)
|
||||||
{
|
{
|
||||||
float4 res;
|
float4 res;
|
||||||
res.r = ((srgb32 >> 0) & 0xFF) / 255.0;
|
res.r = ((srgb32 >> 0) & 0xFF) / 255.0;
|
||||||
|
|||||||
@ -15,19 +15,11 @@
|
|||||||
"addressW = TEXTURE_ADDRESS_CLAMP, " \
|
"addressW = TEXTURE_ADDRESS_CLAMP, " \
|
||||||
"maxAnisotropy = 1)"
|
"maxAnisotropy = 1)"
|
||||||
|
|
||||||
cbuffer cbuff : register(b0)
|
cbuffer cb : register(b0) { struct sh_material_constants g_constants; };
|
||||||
{
|
|
||||||
struct sh_material_constants g_constants;
|
|
||||||
};
|
|
||||||
|
|
||||||
StructuredBuffer<struct sh_material_instance> g_instances : register(t0);
|
StructuredBuffer<struct sh_material_instance> g_instances : register(t0);
|
||||||
|
Texture2D g_textures[] : register(t1);
|
||||||
Texture2D g_texture : register(t1);
|
|
||||||
|
|
||||||
SamplerState g_sampler : register(s0);
|
SamplerState g_sampler : register(s0);
|
||||||
|
|
||||||
/* TODO: Ensure `NonUniformResourceIndex` is used once bindless */
|
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
* Vertex shader
|
* Vertex shader
|
||||||
* ========================== */
|
* ========================== */
|
||||||
@ -48,10 +40,10 @@ struct vs_output {
|
|||||||
DECL(float4, SV_Position);
|
DECL(float4, SV_Position);
|
||||||
DECL(float2, uv);
|
DECL(float2, uv);
|
||||||
DECL(float4, tint_lin);
|
DECL(float4, tint_lin);
|
||||||
|
DECL(uint, texture_nuri);
|
||||||
};
|
};
|
||||||
|
|
||||||
[RootSignature(ROOTSIG)]
|
SH_ENTRY(ROOTSIG) struct vs_output vs(struct vs_input input)
|
||||||
struct vs_output vs(struct vs_input input)
|
|
||||||
{
|
{
|
||||||
struct sh_material_instance instance = g_instances[g_constants.instance_offset + input.SV_InstanceID];
|
struct sh_material_instance instance = g_instances[g_constants.instance_offset + input.SV_InstanceID];
|
||||||
float2 vert = g_quad_verts[input.SV_VertexID];
|
float2 vert = g_quad_verts[input.SV_VertexID];
|
||||||
@ -61,6 +53,7 @@ struct vs_output vs(struct vs_input input)
|
|||||||
output.SV_Position = mul(g_constants.projection, float4(world_pos, 0, 1));
|
output.SV_Position = mul(g_constants.projection, float4(world_pos, 0, 1));
|
||||||
output.uv = instance.uv0 + ((vert + 0.5) * (instance.uv1 - instance.uv0));
|
output.uv = instance.uv0 + ((vert + 0.5) * (instance.uv1 - instance.uv0));
|
||||||
output.tint_lin = linear_from_srgb32(instance.tint_srgb);
|
output.tint_lin = linear_from_srgb32(instance.tint_srgb);
|
||||||
|
output.texture_nuri = instance.texture_nuri;
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,10 +69,9 @@ struct ps_output {
|
|||||||
DECL(float4, SV_Target);
|
DECL(float4, SV_Target);
|
||||||
};
|
};
|
||||||
|
|
||||||
[RootSignature(ROOTSIG)]
|
SH_ENTRY(ROOTSIG) struct ps_output ps(struct ps_input input)
|
||||||
struct ps_output ps(struct ps_input input)
|
|
||||||
{
|
{
|
||||||
struct ps_output output;
|
struct ps_output output;
|
||||||
output.SV_Target = g_texture.Sample(g_sampler, input.vs.uv) * input.vs.tint_lin;
|
output.SV_Target = g_textures[NURI(input.vs.texture_nuri)].Sample(g_sampler, input.vs.uv) * input.vs.tint_lin;
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
#define SH_STRUCT(s) PACK(struct s)
|
#define SH_STRUCT(s) PACK(struct s)
|
||||||
#define SH_DECL(t, n) struct CAT(sh_, t) n
|
#define SH_DECL(t, n) struct CAT(sh_, t) n
|
||||||
|
|
||||||
|
#define SH_ENTRY static /* For intellisense */
|
||||||
|
|
||||||
struct sh_uint { u32 v; };
|
struct sh_uint { u32 v; };
|
||||||
INLINE struct sh_uint sh_uint_from_u32(u32 v)
|
INLINE struct sh_uint sh_uint_from_u32(u32 v)
|
||||||
@ -52,6 +53,7 @@ INLINE struct sh_float2x3 sh_float2x3_from_xform(struct xform v)
|
|||||||
|
|
||||||
#define SH_STRUCT(s) struct s
|
#define SH_STRUCT(s) struct s
|
||||||
#define SH_DECL(t, n) t n
|
#define SH_DECL(t, n) t n
|
||||||
|
# define SH_ENTRY(rootsig) [RootSignature(rootsig)]
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -839,7 +839,7 @@ INTERNAL WORK_TASK_FUNC_DEF(shader_compile_task, comp_arg_raw)
|
|||||||
if (resource_exists(shader_res)) {
|
if (resource_exists(shader_res)) {
|
||||||
struct dx12_include_handler *include_handler = dx12_include_handler_alloc(scratch.arena, pipeline);
|
struct dx12_include_handler *include_handler = dx12_include_handler_alloc(scratch.arena, pipeline);
|
||||||
|
|
||||||
u32 d3d_compile_flags = 0;
|
u32 d3d_compile_flags = D3DCOMPILE_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES;
|
||||||
#if DX12_SHADER_DEBUG
|
#if DX12_SHADER_DEBUG
|
||||||
d3d_compile_flags |= D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION | D3DCOMPILE_ENABLE_STRICTNESS;
|
d3d_compile_flags |= D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION | D3DCOMPILE_ENABLE_STRICTNESS;
|
||||||
#else
|
#else
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user