rename res/gpu -> res/fx
This commit is contained in:
parent
1655d699ce
commit
012d0aaf07
@ -1,6 +1,11 @@
|
|||||||
#include "gpu/common.hlsl"
|
#include "fx/common.hlsl"
|
||||||
|
|
||||||
struct instance {
|
struct fx_material_constant {
|
||||||
|
float4x4 projection;
|
||||||
|
uint instance_offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct fx_material_instance {
|
||||||
float2x3 xf;
|
float2x3 xf;
|
||||||
float2 uv0;
|
float2 uv0;
|
||||||
float2 uv1;
|
float2 uv1;
|
||||||
@ -8,11 +13,6 @@ struct instance {
|
|||||||
float emittance;
|
float emittance;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct constants {
|
|
||||||
float4x4 projection;
|
|
||||||
uint instance_offset;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
* Root Signature
|
* Root Signature
|
||||||
* ========================== */
|
* ========================== */
|
||||||
@ -24,10 +24,10 @@ struct constants {
|
|||||||
|
|
||||||
cbuffer cbuff : register(b0)
|
cbuffer cbuff : register(b0)
|
||||||
{
|
{
|
||||||
struct constants g_constants;
|
struct fx_material_constant g_constant;
|
||||||
};
|
};
|
||||||
|
|
||||||
StructuredBuffer<struct instance> g_instances : register(t0);
|
StructuredBuffer<struct fx_material_instance> g_instances : register(t0);
|
||||||
|
|
||||||
Texture2D g_texture : register(t1);
|
Texture2D g_texture : register(t1);
|
||||||
|
|
||||||
@ -58,15 +58,15 @@ struct vs_output {
|
|||||||
};
|
};
|
||||||
|
|
||||||
[RootSignature(ROOTSIG)]
|
[RootSignature(ROOTSIG)]
|
||||||
struct vs_output vs(uint instance_id : SV_InstanceID, uint vertex_id : SV_VertexID)
|
struct vs_output fx_material_vs(uint instance_id : SV_InstanceID, uint vertex_id : SV_VertexID)
|
||||||
{
|
{
|
||||||
struct instance instance = g_instances[g_constants.instance_offset + instance_id];
|
struct fx_material_instance instance = g_instances[g_constant.instance_offset + instance_id];
|
||||||
float2 vert = g_quad_verts[vertex_id];
|
float2 vert = g_quad_verts[vertex_id];
|
||||||
float2 uv_factor = g_uv_factors[vertex_id];
|
float2 uv_factor = g_uv_factors[vertex_id];
|
||||||
float2 world_pos = mul(instance.xf, float3(vert, 1)).xy;
|
float2 world_pos = mul(instance.xf, float3(vert, 1)).xy;
|
||||||
|
|
||||||
struct vs_output output;
|
struct vs_output output;
|
||||||
output.screen_pos = mul(g_constants.projection, float4(world_pos, 0, 1));
|
output.screen_pos = mul(g_constant.projection, float4(world_pos, 0, 1));
|
||||||
output.uv = instance.uv0 + uv_factor * (instance.uv1 - instance.uv0);
|
output.uv = instance.uv0 + uv_factor * (instance.uv1 - instance.uv0);
|
||||||
output.tint_lin = linear_from_srgb32(instance.tint_srgb);
|
output.tint_lin = linear_from_srgb32(instance.tint_srgb);
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ struct vs_output vs(uint instance_id : SV_InstanceID, uint vertex_id : SV_Vertex
|
|||||||
* ========================== */
|
* ========================== */
|
||||||
|
|
||||||
[RootSignature(ROOTSIG)]
|
[RootSignature(ROOTSIG)]
|
||||||
float4 ps(struct vs_output input) : SV_TARGET
|
float4 fx_material_ps(struct vs_output input) : SV_TARGET
|
||||||
{
|
{
|
||||||
float4 color = g_texture.Sample(g_sampler, input.uv) * input.tint_lin;
|
float4 color = g_texture.Sample(g_sampler, input.uv) * input.tint_lin;
|
||||||
return color;
|
return color;
|
||||||
@ -27,6 +27,8 @@
|
|||||||
#pragma comment(lib, "dxguid")
|
#pragma comment(lib, "dxguid")
|
||||||
#pragma comment(lib, "d3dcompiler")
|
#pragma comment(lib, "d3dcompiler")
|
||||||
|
|
||||||
|
#define FX_CPU 1
|
||||||
|
|
||||||
#define DX12_WAIT_FRAME_LATENCY 1
|
#define DX12_WAIT_FRAME_LATENCY 1
|
||||||
#define DX12_ALLOW_TEARING 1
|
#define DX12_ALLOW_TEARING 1
|
||||||
|
|
||||||
@ -537,11 +539,8 @@ INTERNAL void dx12_init_base(struct sys_window *window)
|
|||||||
* Dx12 pipeline initialization
|
* Dx12 pipeline initialization
|
||||||
* ========================== */
|
* ========================== */
|
||||||
|
|
||||||
/* For shared C-HLSL headers */
|
|
||||||
#define GPU 0
|
|
||||||
|
|
||||||
/* TDOO: Rename 'mesh shader' to 'triangle shader' or something */
|
/* TDOO: Rename 'mesh shader' to 'triangle shader' or something */
|
||||||
/* TODO: Move shader structs into shared file */
|
/* TODO: Move shader structs into shared C-HLSL header file */
|
||||||
|
|
||||||
/* ============= */
|
/* ============= */
|
||||||
/* Mesh pipeline */
|
/* Mesh pipeline */
|
||||||
@ -549,12 +548,12 @@ INTERNAL void dx12_init_base(struct sys_window *window)
|
|||||||
/* ============= */
|
/* ============= */
|
||||||
/* Material pipeline */
|
/* Material pipeline */
|
||||||
|
|
||||||
PACK(struct dx12_buffer_pipeline_uniform {
|
PACK(struct fx_material_constant {
|
||||||
struct mat4x4 vp;
|
struct mat4x4 vp;
|
||||||
u32 instance_offset;
|
u32 instance_offset;
|
||||||
});
|
});
|
||||||
|
|
||||||
PACK(struct dx12_buffer_pipeline_instance {
|
PACK(struct fx_material_instance {
|
||||||
struct xform xf;
|
struct xform xf;
|
||||||
struct v2 uv0;
|
struct v2 uv0;
|
||||||
struct v2 uv1;
|
struct v2 uv1;
|
||||||
@ -579,8 +578,8 @@ INTERNAL void dx12_init_pipelines(void)
|
|||||||
/* Material pipeline */
|
/* Material pipeline */
|
||||||
{
|
{
|
||||||
.name = "material",
|
.name = "material",
|
||||||
.vs = { "gpu/material.hlsl", "vs" },
|
.vs = { "fx/material.hlsl", "fx_material_vs" },
|
||||||
.ps = { "gpu/material.hlsl", "ps" }
|
.ps = { "fx/material.hlsl", "fx_material_ps" }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -742,7 +741,7 @@ INTERNAL WORK_TASK_FUNC_DEF(shader_compile_task, comp_arg_raw)
|
|||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
D3D_SHADER_MACRO defines[] = {
|
D3D_SHADER_MACRO defines[] = {
|
||||||
{ "GPU", "1" },
|
{ "FX_CPU", "0" },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
HRESULT hr = D3DCompile(shader_src.text, shader_src.len, friendly_name_cstr, defines, (ID3DInclude *)&include_handler, shader_desc.func, target, d3d_compile_flags, 0, &blob, &error_blob);
|
HRESULT hr = D3DCompile(shader_src.text, shader_src.len, friendly_name_cstr, defines, (ID3DInclude *)&include_handler, shader_desc.func, target, d3d_compile_flags, 0, &blob, &error_blob);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user