cleanup: remove unused shader/model/image folders from RHI integration tests
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
# D3D12 Integration Tests
|
||||
|
||||
## minimal
|
||||
**后端**: D3D12Device, DXGIFactory, CommandQueue, CommandList, SwapChain
|
||||
**内容**: 最小 D3D12 初始化流程,创建窗口和交换链,无渲染输出
|
||||
|
||||
---
|
||||
|
||||
## triangle
|
||||
**后端**: D3D12Device, DXGIFactory, CommandQueue, CommandList, SwapChain, Buffer, Shader, RootSignature, PipelineState, RenderTargetView, DepthStencilView, Screenshot
|
||||
**内容**:
|
||||
- 基础三角形渲染
|
||||
- 顶点 buffer 上传
|
||||
- HLSL shader 编译 (vs_5_1, ps_5_1)
|
||||
- Root signature + PSO 创建
|
||||
- RenderTarget 切换 (Present ↔ RenderTarget)
|
||||
- 截图功能验证
|
||||
|
||||
---
|
||||
|
||||
## quad
|
||||
**后端**: triangle 的全部 + Texture, DescriptorHeap, ShaderResourceView
|
||||
**内容**:
|
||||
- 四边形纹理采样渲染
|
||||
- Texture 加载与初始化 (stb_image)
|
||||
- DescriptorHeap (CBV_SRV_UAV) + SRV 创建
|
||||
- 静态采样器配置
|
||||
- Root signature descriptor table
|
||||
- SetDescriptorHeaps + SetGraphicsRootDescriptorTable
|
||||
- 截图功能验证
|
||||
|
||||
---
|
||||
|
||||
## render_model
|
||||
**后端**: (TODO)
|
||||
**内容**: 模型渲染 (待实现)
|
||||
@@ -1,99 +0,0 @@
|
||||
struct VertexData{
|
||||
float4 position:POSITION;
|
||||
float4 texcoord:TEXCOORD0;
|
||||
float4 normal:NORMAL;
|
||||
float4 tangent:TANGENT;
|
||||
};
|
||||
|
||||
struct VSOut{
|
||||
float4 position:SV_POSITION;
|
||||
float4 normal:NORMAL;
|
||||
float4 texcoord:TEXCOORD0;
|
||||
};
|
||||
|
||||
static const float PI=3.141592;
|
||||
cbuffer globalConstants:register(b0){
|
||||
float4 misc;
|
||||
};
|
||||
|
||||
Texture2D T_DiffuseTexture:register(t0);
|
||||
SamplerState samplerState:register(s0);
|
||||
|
||||
struct MaterialData{
|
||||
float r;
|
||||
};
|
||||
StructuredBuffer<MaterialData> materialData:register(t0,space1);
|
||||
cbuffer DefaultVertexCB:register(b1){
|
||||
float4x4 ProjectionMatrix;
|
||||
float4x4 ViewMatrix;
|
||||
float4x4 ModelMatrix;
|
||||
float4x4 IT_ModelMatrix;
|
||||
float4x4 ReservedMemory[1020];
|
||||
};
|
||||
|
||||
VSOut MainVS(VertexData inVertexData){
|
||||
VSOut vo;
|
||||
vo.normal=mul(IT_ModelMatrix,inVertexData.normal);
|
||||
float4 positionWS=mul(ModelMatrix,inVertexData.position);
|
||||
float4 positionVS=mul(ViewMatrix,positionWS);
|
||||
vo.position=mul(ProjectionMatrix,positionVS);
|
||||
//vo.position=float4(positionWS.xyz+vo.normal.xyz*sin(misc.x)*0.2f,1.0f);
|
||||
vo.texcoord=inVertexData.texcoord;
|
||||
return vo;
|
||||
}
|
||||
|
||||
[maxvertexcount(4)]
|
||||
void MainGS(triangle VSOut inPoint[3],uint inPrimitiveID:SV_PrimitiveID,
|
||||
inout TriangleStream<VSOut> outTriangleStream){
|
||||
outTriangleStream.Append(inPoint[0]);
|
||||
outTriangleStream.Append(inPoint[1]);
|
||||
outTriangleStream.Append(inPoint[2]);
|
||||
/*VSOut vo;
|
||||
float3 positionWS=inPoint[0].position.xyz;
|
||||
float3 N=normalize(inPoint[0].normal.xyz);
|
||||
vo.normal=float4(N,0.0f);
|
||||
float3 helperVec=abs(N.y)>0.999?float3(0.0f,0.0f,1.0f):float3(0.0f,1.0f,0.0f);
|
||||
float3 tangent=normalize(cross(N,helperVec));//u
|
||||
float3 bitangent=normalize(cross(tangent,N));//v
|
||||
float scale=materialData[inPrimitiveID].r;
|
||||
|
||||
|
||||
float3 p0WS=positionWS-(bitangent*0.5f-tangent*0.5f)*scale;//left bottom
|
||||
float4 p0VS=mul(ViewMatrix,float4(p0WS,1.0f));
|
||||
vo.position=mul(ProjectionMatrix,p0VS);
|
||||
vo.texcoord=float4(0.0f,1.0f,0.0f,0.0f);
|
||||
outTriangleStream.Append(vo);
|
||||
|
||||
float3 p1WS=positionWS-(bitangent*0.5f+tangent*0.5f)*scale;//right bottom
|
||||
float4 p1VS=mul(ViewMatrix,float4(p1WS,1.0f));
|
||||
vo.position=mul(ProjectionMatrix,p1VS);
|
||||
vo.texcoord=float4(1.0f,1.0f,0.0f,0.0f);
|
||||
outTriangleStream.Append(vo);
|
||||
|
||||
float3 p2WS=positionWS+(bitangent*0.5f+tangent*0.5f)*scale;//left top
|
||||
float4 p2VS=mul(ViewMatrix,float4(p2WS,1.0f));
|
||||
vo.position=mul(ProjectionMatrix,p2VS);
|
||||
vo.texcoord=float4(0.0f,0.0f,0.0f,0.0f);
|
||||
outTriangleStream.Append(vo);
|
||||
|
||||
float3 p3WS=positionWS+(bitangent*0.5f-tangent*0.5f)*scale;//right top
|
||||
float4 p3VS=mul(ViewMatrix,float4(p3WS,1.0f));
|
||||
vo.position=mul(ProjectionMatrix,p3VS);
|
||||
vo.texcoord=float4(1.0f,0.0f,0.0f,0.0f);
|
||||
outTriangleStream.Append(vo);*/
|
||||
|
||||
}
|
||||
|
||||
float4 MainPS(VSOut inPSInput):SV_TARGET{
|
||||
float3 N=normalize(inPSInput.normal.xyz);
|
||||
float3 bottomColor=float3(0.1f,0.4f,0.6f);
|
||||
float3 topColor=float3(0.7f,0.7f,0.7f);
|
||||
float theta=asin(N.y);//-PI/2 ~ PI/2
|
||||
theta/=PI;//-0.5~0.5
|
||||
theta+=0.5f;//0.0~1.0
|
||||
float ambientColorIntensity=1.0;
|
||||
float3 ambientColor=lerp(bottomColor,topColor,theta)*ambientColorIntensity;
|
||||
float4 diffuseColor=T_DiffuseTexture.Sample(samplerState,inPSInput.texcoord.xy);
|
||||
float3 surfaceColor=diffuseColor.rgb;
|
||||
return float4(surfaceColor,1.0f);
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
struct VertexData{
|
||||
float4 position:POSITION;
|
||||
float4 texcoord:TEXCOORD0;
|
||||
float4 normal:NORMAL;
|
||||
float4 tangent:TANGENT;
|
||||
};
|
||||
|
||||
struct VSOut{
|
||||
float4 position:SV_POSITION;
|
||||
float4 normal:NORMAL;
|
||||
float4 texcoord:TEXCOORD0;
|
||||
float4 positionWS:TEXCOORD1;
|
||||
};
|
||||
|
||||
static const float PI=3.141592;
|
||||
cbuffer globalConstants:register(b0){
|
||||
float4 misc;
|
||||
};
|
||||
|
||||
cbuffer DefaultVertexCB:register(b1){
|
||||
float4x4 ProjectionMatrix;
|
||||
float4x4 ViewMatrix;
|
||||
float4x4 ModelMatrix;
|
||||
float4x4 IT_ModelMatrix;
|
||||
float4x4 ReservedMemory[1020];
|
||||
};
|
||||
|
||||
VSOut MainVS(VertexData inVertexData){
|
||||
VSOut vo;
|
||||
vo.normal=mul(IT_ModelMatrix,inVertexData.normal);
|
||||
float3 positionMS=inVertexData.position.xyz+vo.normal*sin(misc.x);
|
||||
float4 positionWS=mul(ModelMatrix,float4(positionMS,1.0));
|
||||
float4 positionVS=mul(ViewMatrix,positionWS);
|
||||
vo.position=mul(ProjectionMatrix,positionVS);
|
||||
vo.positionWS=positionWS;
|
||||
vo.texcoord=inVertexData.texcoord;
|
||||
return vo;
|
||||
}
|
||||
|
||||
float4 MainPS(VSOut inPSInput):SV_TARGET{
|
||||
float3 N=normalize(inPSInput.normal.xyz);
|
||||
float3 bottomColor=float3(0.1f,0.4f,0.6f);
|
||||
float3 topColor=float3(0.7f,0.7f,0.7f);
|
||||
float theta=asin(N.y);//-PI/2 ~ PI/2
|
||||
theta/=PI;//-0.5~0.5
|
||||
theta+=0.5f;//0.0~1.0
|
||||
float ambientColorIntensity=0.2;
|
||||
float3 ambientColor=lerp(bottomColor,topColor,theta)*ambientColorIntensity;
|
||||
float3 L=normalize(float3(1.0f,1.0f,-1.0f));
|
||||
|
||||
float diffuseIntensity=max(0.0f,dot(N,L));
|
||||
float3 diffuseLightColor=float3(0.1f,0.4f,0.6f);
|
||||
float3 diffuseColor=diffuseLightColor*diffuseIntensity;
|
||||
|
||||
float3 specularColor=float3(0.0f,0.0f,0.0f);
|
||||
if(diffuseIntensity>0.0f){
|
||||
float3 cameraPositionWS=float3(0.0f,0.0f,0.0f);
|
||||
float3 V=normalize(cameraPositionWS.xyz-inPSInput.positionWS.xyz);
|
||||
float3 R=normalize(reflect(-L,N));
|
||||
float specularIntensity=pow(max(0.0f,dot(V,R)),128.0f);
|
||||
specularColor=float3(1.0f,1.0f,1.0f)*specularIntensity;
|
||||
}
|
||||
float3 surfaceColor=ambientColor+diffuseColor+specularColor;
|
||||
return float4(surfaceColor,1.0f);
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 189 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 189 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 28 KiB |
Binary file not shown.
@@ -1,99 +0,0 @@
|
||||
struct VertexData{
|
||||
float4 position:POSITION;
|
||||
float4 texcoord:TEXCOORD0;
|
||||
float4 normal:NORMAL;
|
||||
float4 tangent:TANGENT;
|
||||
};
|
||||
|
||||
struct VSOut{
|
||||
float4 position:SV_POSITION;
|
||||
float4 normal:NORMAL;
|
||||
float4 texcoord:TEXCOORD0;
|
||||
};
|
||||
|
||||
static const float PI=3.141592;
|
||||
cbuffer globalConstants:register(b0){
|
||||
float4 misc;
|
||||
};
|
||||
|
||||
Texture2D T_DiffuseTexture:register(t0);
|
||||
SamplerState samplerState:register(s0);
|
||||
|
||||
struct MaterialData{
|
||||
float r;
|
||||
};
|
||||
StructuredBuffer<MaterialData> materialData:register(t0,space1);
|
||||
cbuffer DefaultVertexCB:register(b1){
|
||||
float4x4 ProjectionMatrix;
|
||||
float4x4 ViewMatrix;
|
||||
float4x4 ModelMatrix;
|
||||
float4x4 IT_ModelMatrix;
|
||||
float4x4 ReservedMemory[1020];
|
||||
};
|
||||
|
||||
VSOut MainVS(VertexData inVertexData){
|
||||
VSOut vo;
|
||||
vo.normal=mul(IT_ModelMatrix,inVertexData.normal);
|
||||
float4 positionWS=mul(ModelMatrix,inVertexData.position);
|
||||
float4 positionVS=mul(ViewMatrix,positionWS);
|
||||
vo.position=mul(ProjectionMatrix,positionVS);
|
||||
//vo.position=float4(positionWS.xyz+vo.normal.xyz*sin(misc.x)*0.2f,1.0f);
|
||||
vo.texcoord=inVertexData.texcoord;
|
||||
return vo;
|
||||
}
|
||||
|
||||
[maxvertexcount(4)]
|
||||
void MainGS(triangle VSOut inPoint[3],uint inPrimitiveID:SV_PrimitiveID,
|
||||
inout TriangleStream<VSOut> outTriangleStream){
|
||||
outTriangleStream.Append(inPoint[0]);
|
||||
outTriangleStream.Append(inPoint[1]);
|
||||
outTriangleStream.Append(inPoint[2]);
|
||||
/*VSOut vo;
|
||||
float3 positionWS=inPoint[0].position.xyz;
|
||||
float3 N=normalize(inPoint[0].normal.xyz);
|
||||
vo.normal=float4(N,0.0f);
|
||||
float3 helperVec=abs(N.y)>0.999?float3(0.0f,0.0f,1.0f):float3(0.0f,1.0f,0.0f);
|
||||
float3 tangent=normalize(cross(N,helperVec));//u
|
||||
float3 bitangent=normalize(cross(tangent,N));//v
|
||||
float scale=materialData[inPrimitiveID].r;
|
||||
|
||||
|
||||
float3 p0WS=positionWS-(bitangent*0.5f-tangent*0.5f)*scale;//left bottom
|
||||
float4 p0VS=mul(ViewMatrix,float4(p0WS,1.0f));
|
||||
vo.position=mul(ProjectionMatrix,p0VS);
|
||||
vo.texcoord=float4(0.0f,1.0f,0.0f,0.0f);
|
||||
outTriangleStream.Append(vo);
|
||||
|
||||
float3 p1WS=positionWS-(bitangent*0.5f+tangent*0.5f)*scale;//right bottom
|
||||
float4 p1VS=mul(ViewMatrix,float4(p1WS,1.0f));
|
||||
vo.position=mul(ProjectionMatrix,p1VS);
|
||||
vo.texcoord=float4(1.0f,1.0f,0.0f,0.0f);
|
||||
outTriangleStream.Append(vo);
|
||||
|
||||
float3 p2WS=positionWS+(bitangent*0.5f+tangent*0.5f)*scale;//left top
|
||||
float4 p2VS=mul(ViewMatrix,float4(p2WS,1.0f));
|
||||
vo.position=mul(ProjectionMatrix,p2VS);
|
||||
vo.texcoord=float4(0.0f,0.0f,0.0f,0.0f);
|
||||
outTriangleStream.Append(vo);
|
||||
|
||||
float3 p3WS=positionWS+(bitangent*0.5f-tangent*0.5f)*scale;//right top
|
||||
float4 p3VS=mul(ViewMatrix,float4(p3WS,1.0f));
|
||||
vo.position=mul(ProjectionMatrix,p3VS);
|
||||
vo.texcoord=float4(1.0f,0.0f,0.0f,0.0f);
|
||||
outTriangleStream.Append(vo);*/
|
||||
|
||||
}
|
||||
|
||||
float4 MainPS(VSOut inPSInput):SV_TARGET{
|
||||
float3 N=normalize(inPSInput.normal.xyz);
|
||||
float3 bottomColor=float3(0.1f,0.4f,0.6f);
|
||||
float3 topColor=float3(0.7f,0.7f,0.7f);
|
||||
float theta=asin(N.y);//-PI/2 ~ PI/2
|
||||
theta/=PI;//-0.5~0.5
|
||||
theta+=0.5f;//0.0~1.0
|
||||
float ambientColorIntensity=1.0;
|
||||
float3 ambientColor=lerp(bottomColor,topColor,theta)*ambientColorIntensity;
|
||||
float4 diffuseColor=T_DiffuseTexture.Sample(samplerState,inPSInput.texcoord.xy);
|
||||
float3 surfaceColor=diffuseColor.rgb;
|
||||
return float4(surfaceColor,1.0f);
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
struct VertexData{
|
||||
float4 position:POSITION;
|
||||
float4 texcoord:TEXCOORD0;
|
||||
float4 normal:NORMAL;
|
||||
float4 tangent:TANGENT;
|
||||
};
|
||||
|
||||
struct VSOut{
|
||||
float4 position:SV_POSITION;
|
||||
float4 normal:NORMAL;
|
||||
float4 texcoord:TEXCOORD0;
|
||||
float4 positionWS:TEXCOORD1;
|
||||
};
|
||||
|
||||
static const float PI=3.141592;
|
||||
cbuffer globalConstants:register(b0){
|
||||
float4 misc;
|
||||
};
|
||||
|
||||
cbuffer DefaultVertexCB:register(b1){
|
||||
float4x4 ProjectionMatrix;
|
||||
float4x4 ViewMatrix;
|
||||
float4x4 ModelMatrix;
|
||||
float4x4 IT_ModelMatrix;
|
||||
float4x4 ReservedMemory[1020];
|
||||
};
|
||||
|
||||
VSOut MainVS(VertexData inVertexData){
|
||||
VSOut vo;
|
||||
vo.normal=mul(IT_ModelMatrix,inVertexData.normal);
|
||||
float3 positionMS=inVertexData.position.xyz+vo.normal*sin(misc.x);
|
||||
float4 positionWS=mul(ModelMatrix,float4(positionMS,1.0));
|
||||
float4 positionVS=mul(ViewMatrix,positionWS);
|
||||
vo.position=mul(ProjectionMatrix,positionVS);
|
||||
vo.positionWS=positionWS;
|
||||
vo.texcoord=inVertexData.texcoord;
|
||||
return vo;
|
||||
}
|
||||
|
||||
float4 MainPS(VSOut inPSInput):SV_TARGET{
|
||||
float3 N=normalize(inPSInput.normal.xyz);
|
||||
float3 bottomColor=float3(0.1f,0.4f,0.6f);
|
||||
float3 topColor=float3(0.7f,0.7f,0.7f);
|
||||
float theta=asin(N.y);//-PI/2 ~ PI/2
|
||||
theta/=PI;//-0.5~0.5
|
||||
theta+=0.5f;//0.0~1.0
|
||||
float ambientColorIntensity=0.2;
|
||||
float3 ambientColor=lerp(bottomColor,topColor,theta)*ambientColorIntensity;
|
||||
float3 L=normalize(float3(1.0f,1.0f,-1.0f));
|
||||
|
||||
float diffuseIntensity=max(0.0f,dot(N,L));
|
||||
float3 diffuseLightColor=float3(0.1f,0.4f,0.6f);
|
||||
float3 diffuseColor=diffuseLightColor*diffuseIntensity;
|
||||
|
||||
float3 specularColor=float3(0.0f,0.0f,0.0f);
|
||||
if(diffuseIntensity>0.0f){
|
||||
float3 cameraPositionWS=float3(0.0f,0.0f,0.0f);
|
||||
float3 V=normalize(cameraPositionWS.xyz-inPSInput.positionWS.xyz);
|
||||
float3 R=normalize(reflect(-L,N));
|
||||
float specularIntensity=pow(max(0.0f,dot(V,R)),128.0f);
|
||||
specularColor=float3(1.0f,1.0f,1.0f)*specularIntensity;
|
||||
}
|
||||
float3 surfaceColor=ambientColor+diffuseColor+specularColor;
|
||||
return float4(surfaceColor,1.0f);
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
struct Vertex {
|
||||
float4 pos : POSITION;
|
||||
float4 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VSOut {
|
||||
float4 pos : SV_POSITION;
|
||||
float4 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
VSOut MainVS(Vertex v) {
|
||||
VSOut o;
|
||||
o.pos = v.pos;
|
||||
o.texcoord = v.texcoord;
|
||||
return o;
|
||||
}
|
||||
|
||||
Texture2D T_DiffuseTexture : register(t0);
|
||||
SamplerState samplerState : register(s0);
|
||||
|
||||
float4 MainPS(VSOut i) : SV_TARGET {
|
||||
return T_DiffuseTexture.Sample(samplerState, i.texcoord.xy);
|
||||
}
|
||||
@@ -9,3 +9,4 @@ enable_testing()
|
||||
add_subdirectory(minimal)
|
||||
add_subdirectory(triangle)
|
||||
add_subdirectory(quad)
|
||||
add_subdirectory(sphere)
|
||||
|
||||
Reference in New Issue
Block a user