diff --git a/tests/RHI/D3D12/integration/README.md b/tests/RHI/D3D12/integration/README.md deleted file mode 100644 index 58b2ec5b..00000000 --- a/tests/RHI/D3D12/integration/README.md +++ /dev/null @@ -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) -**内容**: 模型渲染 (待实现) diff --git a/tests/RHI/D3D12/integration/minimal/Res/Shader/gs.hlsl b/tests/RHI/D3D12/integration/minimal/Res/Shader/gs.hlsl deleted file mode 100644 index 66a3f189..00000000 --- a/tests/RHI/D3D12/integration/minimal/Res/Shader/gs.hlsl +++ /dev/null @@ -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: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 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); -} \ No newline at end of file diff --git a/tests/RHI/D3D12/integration/minimal/Res/Shader/ndctriangle.hlsl b/tests/RHI/D3D12/integration/minimal/Res/Shader/ndctriangle.hlsl deleted file mode 100644 index edee8bf9..00000000 --- a/tests/RHI/D3D12/integration/minimal/Res/Shader/ndctriangle.hlsl +++ /dev/null @@ -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); -} \ No newline at end of file diff --git a/tests/RHI/D3D12/integration/sphere/Image/earth.png b/tests/RHI/D3D12/integration/sphere/Image/earth.png deleted file mode 100644 index 663081b5..00000000 Binary files a/tests/RHI/D3D12/integration/sphere/Image/earth.png and /dev/null differ diff --git a/tests/RHI/D3D12/integration/sphere/Image/earth_d.jpg b/tests/RHI/D3D12/integration/sphere/Image/earth_d.jpg deleted file mode 100644 index 663081b5..00000000 Binary files a/tests/RHI/D3D12/integration/sphere/Image/earth_d.jpg and /dev/null differ diff --git a/tests/RHI/D3D12/integration/sphere/Image/head.png b/tests/RHI/D3D12/integration/sphere/Image/head.png deleted file mode 100644 index 055c373f..00000000 Binary files a/tests/RHI/D3D12/integration/sphere/Image/head.png and /dev/null differ diff --git a/tests/RHI/D3D12/integration/sphere/Model/Sphere.lhsm b/tests/RHI/D3D12/integration/sphere/Model/Sphere.lhsm deleted file mode 100644 index b9e0c40d..00000000 Binary files a/tests/RHI/D3D12/integration/sphere/Model/Sphere.lhsm and /dev/null differ diff --git a/tests/RHI/D3D12/integration/sphere/Shader/gs.hlsl b/tests/RHI/D3D12/integration/sphere/Shader/gs.hlsl deleted file mode 100644 index 66a3f189..00000000 --- a/tests/RHI/D3D12/integration/sphere/Shader/gs.hlsl +++ /dev/null @@ -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: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 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); -} \ No newline at end of file diff --git a/tests/RHI/D3D12/integration/sphere/Shader/ndctriangle.hlsl b/tests/RHI/D3D12/integration/sphere/Shader/ndctriangle.hlsl deleted file mode 100644 index edee8bf9..00000000 --- a/tests/RHI/D3D12/integration/sphere/Shader/ndctriangle.hlsl +++ /dev/null @@ -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); -} \ No newline at end of file diff --git a/tests/RHI/D3D12/integration/sphere/Shader/sphere.hlsl b/tests/RHI/D3D12/integration/sphere/Shader/sphere.hlsl deleted file mode 100644 index d3b333d6..00000000 --- a/tests/RHI/D3D12/integration/sphere/Shader/sphere.hlsl +++ /dev/null @@ -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); -} \ No newline at end of file diff --git a/tests/RHI/OpenGL/integration/CMakeLists.txt b/tests/RHI/OpenGL/integration/CMakeLists.txt index 02ccd0ac..55e2caf6 100644 --- a/tests/RHI/OpenGL/integration/CMakeLists.txt +++ b/tests/RHI/OpenGL/integration/CMakeLists.txt @@ -9,3 +9,4 @@ enable_testing() add_subdirectory(minimal) add_subdirectory(triangle) add_subdirectory(quad) +add_subdirectory(sphere)