create shader headers
This commit is contained in:
parent
bb8f105309
commit
781e6ff75a
@ -770,7 +770,7 @@ Struct(SamplerStateHandle) { u32 v; };
|
|||||||
* Other constants past the max can be used by the graphics
|
* Other constants past the max can be used by the graphics
|
||||||
* implementation backend layer.
|
* implementation backend layer.
|
||||||
*/
|
*/
|
||||||
#define MaxShaderConstants (8)
|
#define NumGeneralPurposeShaderConstants (8)
|
||||||
|
|
||||||
#if IsLanguageC
|
#if IsLanguageC
|
||||||
#define ForceShaderConstant(type, name, slot) \
|
#define ForceShaderConstant(type, name, slot) \
|
||||||
@ -778,7 +778,7 @@ Struct(SamplerStateHandle) { u32 v; };
|
|||||||
Struct(name##__shaderconstanttype) { type v; }
|
Struct(name##__shaderconstanttype) { type v; }
|
||||||
#define ShaderConstant(type, name, slot) \
|
#define ShaderConstant(type, name, slot) \
|
||||||
StaticAssert(sizeof(type) <= 4); \
|
StaticAssert(sizeof(type) <= 4); \
|
||||||
StaticAssert(slot < MaxShaderConstants); \
|
StaticAssert(slot < NumGeneralPurposeShaderConstants); \
|
||||||
ForceShaderConstant(type, name, slot)
|
ForceShaderConstant(type, name, slot)
|
||||||
#elif IsLanguageG
|
#elif IsLanguageG
|
||||||
#define ForceShaderConstant(type, name, slot) cbuffer name : register(b##slot) { type name; }
|
#define ForceShaderConstant(type, name, slot) cbuffer name : register(b##slot) { type name; }
|
||||||
|
|||||||
@ -4,7 +4,9 @@
|
|||||||
//- Api
|
//- Api
|
||||||
|
|
||||||
@IncludeC gpu_dx12_core.h
|
@IncludeC gpu_dx12_core.h
|
||||||
|
@IncludeC gpu_dx12_shader_core.cgh
|
||||||
|
|
||||||
|
@IncludeG gpu_dx12_shader_core.cgh
|
||||||
@IncludeG gpu_dx12_shader_core.gh
|
@IncludeG gpu_dx12_shader_core.gh
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
|||||||
@ -247,8 +247,8 @@ void GPU_Bootstrap(void)
|
|||||||
ID3D10Blob *blob = 0;
|
ID3D10Blob *blob = 0;
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
D3D12_ROOT_PARAMETER params[MaxShaderConstants] = ZI;
|
D3D12_ROOT_PARAMETER params[GPU_D12_NumShaderConstants] = ZI;
|
||||||
for (i32 slot = 0; slot < MaxShaderConstants; ++slot)
|
for (i32 slot = 0; slot < GPU_D12_NumShaderConstants; ++slot)
|
||||||
{
|
{
|
||||||
D3D12_ROOT_PARAMETER *param = ¶ms[slot];
|
D3D12_ROOT_PARAMETER *param = ¶ms[slot];
|
||||||
param->ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
|
param->ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
|
||||||
@ -1526,15 +1526,13 @@ void GPU_CommitCommandListEx(GPU_CommandListHandle cl_handle, u64 fence_ops_coun
|
|||||||
GPU_D12_Pipeline *bound_pipeline = 0;
|
GPU_D12_Pipeline *bound_pipeline = 0;
|
||||||
|
|
||||||
/* Constants state */
|
/* Constants state */
|
||||||
u64 slotted_constants[MaxShaderConstants];
|
u64 slotted_constants[GPU_D12_NumShaderConstants];
|
||||||
u64 bound_compute_constants[MaxShaderConstants];
|
u64 bound_compute_constants[GPU_D12_NumShaderConstants];
|
||||||
u64 bound_graphics_constants[MaxShaderConstants];
|
u64 bound_graphics_constants[GPU_D12_NumShaderConstants];
|
||||||
for (i32 i = 0; i < countof(slotted_constants); ++i) { slotted_constants[i] = 0; } /* Zero initialze all constant slots */
|
for (i32 i = 0; i < countof(slotted_constants); ++i) { slotted_constants[i] = 0; } /* Zero initialze all constant slots */
|
||||||
for (i32 i = 0; i < countof(bound_compute_constants); ++i) { bound_compute_constants[i] = U64Max; }
|
for (i32 i = 0; i < countof(bound_compute_constants); ++i) { bound_compute_constants[i] = U64Max; }
|
||||||
for (i32 i = 0; i < countof(bound_graphics_constants); ++i) { bound_graphics_constants[i] = U64Max; }
|
for (i32 i = 0; i < countof(bound_graphics_constants); ++i) { bound_graphics_constants[i] = U64Max; }
|
||||||
|
|
||||||
slotted_constants[MaxShaderConstants - 1] = queue_kind == queue_kind == GPU_QueueKind_AsyncCompute; /* IsAsyncCompute constant */
|
|
||||||
|
|
||||||
/* Rasterizer state */
|
/* Rasterizer state */
|
||||||
D3D12_VIEWPORT bound_viewport = ZI;
|
D3D12_VIEWPORT bound_viewport = ZI;
|
||||||
D3D12_RECT bound_scissor = ZI;
|
D3D12_RECT bound_scissor = ZI;
|
||||||
@ -1851,7 +1849,7 @@ void GPU_CommitCommandListEx(GPU_CommandListHandle cl_handle, u64 fence_ops_coun
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Update root constants */
|
/* Update root constants */
|
||||||
for (i32 slot = 0; slot < MaxShaderConstants; ++slot)
|
for (i32 slot = 0; slot < countof(slotted_constants); ++slot)
|
||||||
{
|
{
|
||||||
if (bound_compute_constants[slot] != slotted_constants[slot])
|
if (bound_compute_constants[slot] != slotted_constants[slot])
|
||||||
{
|
{
|
||||||
@ -1965,7 +1963,7 @@ void GPU_CommitCommandListEx(GPU_CommandListHandle cl_handle, u64 fence_ops_coun
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Update root constants */
|
/* Update root constants */
|
||||||
for (i32 slot = 0; slot < MaxShaderConstants; ++slot)
|
for (i32 slot = 0; slot < countof(slotted_constants); ++slot)
|
||||||
{
|
{
|
||||||
if (bound_graphics_constants[slot] != slotted_constants[slot])
|
if (bound_graphics_constants[slot] != slotted_constants[slot])
|
||||||
{
|
{
|
||||||
|
|||||||
11
src/gpu/gpu_dx12/gpu_dx12_shader_core.cgh
Normal file
11
src/gpu/gpu_dx12/gpu_dx12_shader_core.cgh
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Debug types
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Global constants
|
||||||
|
|
||||||
|
/* Slots below assume they won't overlap user defined constants */
|
||||||
|
StaticAssert(NumGeneralPurposeShaderConstants == 8);
|
||||||
|
|
||||||
|
ForceShaderConstant(RWByteAddressBufferHandle, GPU_D12_DebugPrintBuff, 8);
|
||||||
|
#define GPU_D12_NumShaderConstants (9)
|
||||||
@ -1,16 +1,6 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Debug types
|
//~ Debug types
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
//~ Debug globals
|
|
||||||
|
|
||||||
// RWByteAddressBufferHandle print_buff;
|
|
||||||
|
|
||||||
StaticAssert(MaxShaderConstants == 8); /* Slots used below assume they won't overlap user shader constants */
|
|
||||||
ForceShaderConstant(RWByteAddressBufferHandle, GPU_D12_DebugPrintBuff, 9);
|
|
||||||
|
|
||||||
// cbuffer GPU_D12_DebugPrintCbuff_ : register(b9) { RWByteAddressBufferHandle print_buff; }
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookimpl Shader printf
|
//~ @hookimpl Shader printf
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
@IncludeC pp_vis_core.h
|
@IncludeC pp_vis_core.h
|
||||||
|
|
||||||
@IncludeG pp_vis_shaders.cgh
|
@IncludeG pp_vis_shaders.cgh
|
||||||
|
@IncludeG pp_vis_shaders.gh
|
||||||
|
|
||||||
@Bootstrap V_Bootstrap
|
@Bootstrap V_Bootstrap
|
||||||
|
|
||||||
|
|||||||
@ -18,17 +18,6 @@ ComputeShader2D(V_BackdropCS, 8, 8)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Quad shader
|
//~ Quad shader
|
||||||
|
|
||||||
Struct(V_DQuadPSInput)
|
|
||||||
{
|
|
||||||
Semantic(Vec4, SV_Position);
|
|
||||||
Semantic(nointerpolation u32, quad_idx);
|
|
||||||
};
|
|
||||||
|
|
||||||
Struct(V_DQuadPSOutput)
|
|
||||||
{
|
|
||||||
Semantic(Vec4, SV_Target0);
|
|
||||||
};
|
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Vertex shader
|
//- Vertex shader
|
||||||
|
|
||||||
@ -70,18 +59,6 @@ PixelShader(V_DQuadPS, V_DQuadPSOutput, V_DQuadPSInput input)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Shape shader
|
//~ Shape shader
|
||||||
|
|
||||||
Struct(V_DVertPSInput)
|
|
||||||
{
|
|
||||||
|
|
||||||
Semantic(Vec4, SV_Position);
|
|
||||||
Semantic(Vec4, color_lin);
|
|
||||||
};
|
|
||||||
|
|
||||||
Struct(V_DVertPSOutput)
|
|
||||||
{
|
|
||||||
Semantic(Vec4, SV_Target0);
|
|
||||||
};
|
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Vertex shader
|
//- Vertex shader
|
||||||
|
|
||||||
|
|||||||
42
src/pp/pp_vis/pp_vis_shaders.gh
Normal file
42
src/pp/pp_vis/pp_vis_shaders.gh
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Quad shader types
|
||||||
|
|
||||||
|
Struct(V_DQuadPSInput)
|
||||||
|
{
|
||||||
|
Semantic(Vec4, SV_Position);
|
||||||
|
Semantic(nointerpolation u32, quad_idx);
|
||||||
|
};
|
||||||
|
|
||||||
|
Struct(V_DQuadPSOutput)
|
||||||
|
{
|
||||||
|
Semantic(Vec4, SV_Target0);
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Shape shader types
|
||||||
|
|
||||||
|
Struct(V_DVertPSInput)
|
||||||
|
{
|
||||||
|
|
||||||
|
Semantic(Vec4, SV_Position);
|
||||||
|
Semantic(Vec4, color_lin);
|
||||||
|
};
|
||||||
|
|
||||||
|
Struct(V_DVertPSOutput)
|
||||||
|
{
|
||||||
|
Semantic(Vec4, SV_Target0);
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Shaders
|
||||||
|
|
||||||
|
//- Backdrop
|
||||||
|
ComputeShader2D(V_BackdropCS, 8, 8);
|
||||||
|
|
||||||
|
//- Quad
|
||||||
|
VertexShader(V_DQuadVS, V_DQuadPSInput);
|
||||||
|
PixelShader(V_DQuadPS, V_DQuadPSOutput, V_DQuadPSInput input);
|
||||||
|
|
||||||
|
//- Shape
|
||||||
|
VertexShader(V_DVertVS, V_DVertPSInput);
|
||||||
|
PixelShader(V_DVertPS, V_DVertPSOutput, V_DVertPSInput input);
|
||||||
@ -25,6 +25,7 @@
|
|||||||
@IncludeC ui_shaders.cgh
|
@IncludeC ui_shaders.cgh
|
||||||
|
|
||||||
@IncludeG ui_shaders.cgh
|
@IncludeG ui_shaders.cgh
|
||||||
|
@IncludeG ui_shaders.gh
|
||||||
|
|
||||||
@Bootstrap UI_Bootstrap
|
@Bootstrap UI_Bootstrap
|
||||||
|
|
||||||
|
|||||||
@ -1,21 +1,5 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Rect
|
//~ Rect shader
|
||||||
|
|
||||||
Struct(UI_DRectPSInput)
|
|
||||||
{
|
|
||||||
Semantic(Vec4, sv_position);
|
|
||||||
Semantic(nointerpolation u32, rect_idx);
|
|
||||||
Semantic(Vec4, background_lin);
|
|
||||||
Semantic(Vec4, border_lin);
|
|
||||||
Semantic(Vec4, tint_lin);
|
|
||||||
Semantic(Vec2, rect_uv);
|
|
||||||
Semantic(Vec2, tex_uv);
|
|
||||||
};
|
|
||||||
|
|
||||||
Struct(UI_DRectPSOutput)
|
|
||||||
{
|
|
||||||
Semantic(Vec4, sv_target0);
|
|
||||||
};
|
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Vertex shader
|
//- Vertex shader
|
||||||
@ -135,18 +119,7 @@ PixelShader(UI_DRectPS, UI_DRectPSOutput, UI_DRectPSInput input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Blit
|
//~ Blit shader
|
||||||
|
|
||||||
Struct(UI_BlitPSInput)
|
|
||||||
{
|
|
||||||
Semantic(Vec4, SV_Position);
|
|
||||||
Semantic(Vec2, src_uv);
|
|
||||||
};
|
|
||||||
|
|
||||||
Struct(UI_BlitPSOutput)
|
|
||||||
{
|
|
||||||
Semantic(Vec4, SV_Target0);
|
|
||||||
};
|
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Vertex shader
|
//- Vertex shader
|
||||||
|
|||||||
43
src/ui/ui_shaders.gh
Normal file
43
src/ui/ui_shaders.gh
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Rect shader types
|
||||||
|
|
||||||
|
Struct(UI_DRectPSInput)
|
||||||
|
{
|
||||||
|
Semantic(Vec4, sv_position);
|
||||||
|
Semantic(nointerpolation u32, rect_idx);
|
||||||
|
Semantic(Vec4, background_lin);
|
||||||
|
Semantic(Vec4, border_lin);
|
||||||
|
Semantic(Vec4, tint_lin);
|
||||||
|
Semantic(Vec2, rect_uv);
|
||||||
|
Semantic(Vec2, tex_uv);
|
||||||
|
};
|
||||||
|
|
||||||
|
Struct(UI_DRectPSOutput)
|
||||||
|
{
|
||||||
|
Semantic(Vec4, sv_target0);
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Blit shader types
|
||||||
|
|
||||||
|
Struct(UI_BlitPSInput)
|
||||||
|
{
|
||||||
|
Semantic(Vec4, SV_Position);
|
||||||
|
Semantic(Vec2, src_uv);
|
||||||
|
};
|
||||||
|
|
||||||
|
Struct(UI_BlitPSOutput)
|
||||||
|
{
|
||||||
|
Semantic(Vec4, SV_Target0);
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Shaders
|
||||||
|
|
||||||
|
//- Rect
|
||||||
|
VertexShader(UI_DRectVS, UI_DRectPSInput);
|
||||||
|
PixelShader(UI_DRectPS, UI_DRectPSOutput, UI_DRectPSInput input);
|
||||||
|
|
||||||
|
//- Blit
|
||||||
|
VertexShader(UI_BlitVS, UI_BlitPSInput);
|
||||||
|
PixelShader(UI_BlitPS, UI_BlitPSOutput, UI_BlitPSInput input);
|
||||||
Loading…
Reference in New Issue
Block a user