diff --git a/Core/Graphics/Renderer.cpp b/Core/Graphics/Renderer.cpp index dd568fe..b22d2a0 100644 --- a/Core/Graphics/Renderer.cpp +++ b/Core/Graphics/Renderer.cpp @@ -105,7 +105,7 @@ namespace CGL::Graphics #elif defined(CGL_RHI_OPENGL) SetVertexShader_OPENGL(shader); #elif defined (CGL_RHI_METAL) - SetVertexShader_METAL(shader); + SetVertexShader_METAL(shader); #endif } @@ -116,7 +116,7 @@ namespace CGL::Graphics #elif defined(CGL_RHI_OPENGL) SetPixelShader_OPENGL(shader); #elif defined (CGL_RHI_METAL) - SetPixelShader_METAL(shader); + SetPixelShader_METAL(shader); #endif } @@ -135,7 +135,7 @@ namespace CGL::Graphics #if defined(CGL_RHI_OPENGL) glUseProgram(material.m_id); #elif defined (CGL_RHI_METAL) - SetRenderPipeline_METAL(); + SetRenderPipeline_METAL(); #endif } @@ -147,7 +147,7 @@ namespace CGL::Graphics #elif defined(CGL_RHI_OPENGL) SetVertexBuffer_OPENGL(buffer); #elif defined (CGL_RHI_METAL) - SetVertexBuffer_METAL(buffer); + SetVertexBuffer_METAL(buffer); #endif } @@ -158,7 +158,7 @@ namespace CGL::Graphics #elif defined(CGL_RHI_OPENGL) SetIndexBuffer_OPENGL(buffer); #elif defined (CGL_RHI_METAL) - SetIndexBuffer_METAL(buffer); + SetIndexBuffer_METAL(buffer); #endif } @@ -171,7 +171,7 @@ namespace CGL::Graphics #elif defined(CGL_RHI_OPENGL) ShaderCompileResult result = CompileVertexShader_OPENGL(source, outShader); #elif defined (CGL_RHI_METAL) - ShaderCompileResult result = CompileVertexShader_METAL(source, outShader); + ShaderCompileResult result = CompileVertexShader_METAL(source, outShader); #endif ShaderCompiler::ReportResult(result, source.Name.data()); return result.Status == ShaderCompileStatus::Success || result.Status == ShaderCompileStatus::HasWarnings; @@ -186,7 +186,7 @@ namespace CGL::Graphics #elif defined(CGL_RHI_OPENGL) ShaderCompileResult result = CompilePixelShader_OPENGL(source, outShader); #elif defined (CGL_RHI_METAL) - ShaderCompileResult result = CompilePixelShader_METAL(source, outShader); + ShaderCompileResult result = CompilePixelShader_METAL(source, outShader); #endif ShaderCompiler::ReportResult(result, source.Name.data()); return result.Status == ShaderCompileStatus::Success || result.Status == ShaderCompileStatus::HasWarnings; @@ -199,7 +199,7 @@ namespace CGL::Graphics #elif defined(CGL_RHI_OPENGL) return CreateVertexBuffer_OPENGL(source); #elif defined (CGL_RHI_METAL) - return CreateVertexBuffer_METAL(source); + return CreateVertexBuffer_METAL(source); #endif } @@ -210,7 +210,7 @@ namespace CGL::Graphics #elif defined(CGL_RHI_OPENGL) return CreateIndexBuffer_OPENGL(source); #elif defined (CGL_RHI_METAL) - return CreateIndexBuffer_METAL(source); + return CreateIndexBuffer_METAL(source); #endif } @@ -249,7 +249,7 @@ namespace CGL::Graphics #elif defined(CGL_RHI_OPENGL) Draw_OPENGL(vertexCount, startVertex); #elif defined (CGL_RHI_METAL) - Draw_METAL(vertexCount, startVertex); + Draw_METAL(vertexCount, startVertex); #endif } @@ -260,7 +260,7 @@ namespace CGL::Graphics #elif defined(CGL_RHI_OPENGL) DrawIndexed_OPENGL(indexCount, startIndex, baseVertex); #elif defined (CGL_RHI_METAL) - DrawIndexed_METAL(indexCount, startIndex, baseVertex); + DrawIndexed_METAL(indexCount, startIndex, baseVertex); #endif } } diff --git a/Core/Graphics/Renderer.h b/Core/Graphics/Renderer.h index 4e87ea4..866dce1 100644 --- a/Core/Graphics/Renderer.h +++ b/Core/Graphics/Renderer.h @@ -111,18 +111,18 @@ namespace CGL::Graphics void BeginFrame_METAL(); void EndFrame_METAL(); void Resize_METAL(u32 width, u32 height); - void SetRenderPipeline_METAL(); - void SetPrimitiveTopology_METAL(PrimitiveType topology); - void SetVertexShader_METAL(const VertexShader& shader); - void SetPixelShader_METAL(const PixelShader& shader); - void SetVertexBuffer_METAL(const VertexBuffer& buffer); - void SetIndexBuffer_METAL(const IndexBuffer& buffer); - ShaderCompileResult CompileVertexShader_METAL(const ShaderSource& source, VertexShader* outShader); - ShaderCompileResult CompilePixelShader_METAL(const ShaderSource& source, PixelShader* outShader); - VertexBuffer CreateVertexBuffer_METAL(const BufferSource& source); - IndexBuffer CreateIndexBuffer_METAL(const BufferSource& source); - void Draw_METAL(u32 vertexCount, u32 startVertex = 0); - void DrawIndexed_METAL(u32 indexCount, u32 startIndex = 0, u32 baseVertex = 0); + void SetRenderPipeline_METAL(); + void SetPrimitiveTopology_METAL(PrimitiveType topology); + void SetVertexShader_METAL(const VertexShader& shader); + void SetPixelShader_METAL(const PixelShader& shader); + void SetVertexBuffer_METAL(const VertexBuffer& buffer); + void SetIndexBuffer_METAL(const IndexBuffer& buffer); + ShaderCompileResult CompileVertexShader_METAL(const ShaderSource& source, VertexShader* outShader); + ShaderCompileResult CompilePixelShader_METAL(const ShaderSource& source, PixelShader* outShader); + VertexBuffer CreateVertexBuffer_METAL(const BufferSource& source); + IndexBuffer CreateIndexBuffer_METAL(const BufferSource& source); + void Draw_METAL(u32 vertexCount, u32 startVertex = 0); + void DrawIndexed_METAL(u32 indexCount, u32 startIndex = 0, u32 baseVertex = 0); METALRendererImpl* GetImpl() const; #endif diff --git a/Core/xmake.lua b/Core/xmake.lua index e238639..267f26d 100644 --- a/Core/xmake.lua +++ b/Core/xmake.lua @@ -5,7 +5,7 @@ target("VisualizerCore") set_default(false) set_kind("static") - set_group("CrossGL") + set_group("CrossVL") add_packages("libsdl", "directxmath") set_options("rhi") diff --git a/Samples/HelloTriangle/Assets/DirectX/HelloTriangleVS.hlsl b/Samples/HelloTriangle/Assets/DirectX/HelloTriangleVS.hlsl index 3600b8a..db4b5bc 100644 --- a/Samples/HelloTriangle/Assets/DirectX/HelloTriangleVS.hlsl +++ b/Samples/HelloTriangle/Assets/DirectX/HelloTriangleVS.hlsl @@ -13,7 +13,7 @@ struct VS_OUTPUT VS_OUTPUT main(VS_INPUT input) { VS_OUTPUT output = (VS_OUTPUT)0; - output.Position = float4(input.Position, 1.0); + output.Position = input.Position; output.Color = input.Color; return output; } diff --git a/Samples/SpinningCube/Assets/DirectX/SpinningCubeVS.hlsl b/Samples/SpinningCube/Assets/DirectX/SpinningCubeVS.hlsl index c1177f1..e172154 100644 --- a/Samples/SpinningCube/Assets/DirectX/SpinningCubeVS.hlsl +++ b/Samples/SpinningCube/Assets/DirectX/SpinningCubeVS.hlsl @@ -7,7 +7,7 @@ cbuffer FrameData : register(b0) struct VS_INPUT { - float3 Position : POSITION; + float4 Position : POSITION; float3 Color : COLOR0; }; @@ -21,7 +21,7 @@ VS_OUTPUT main(VS_INPUT input) { VS_OUTPUT output = (VS_OUTPUT)0; - output.Position = float4(input.Position, 1.0); + output.Position = input.Position; output.Position = mul(output.Position, WorldMatrix); output.Position = mul(output.Position, ViewMatrix); output.Position = mul(output.Position, ProjMatrix); diff --git a/Samples/SpinningCube/SpinningCube.cpp b/Samples/SpinningCube/SpinningCube.cpp index 0c8d2a4..d8a4b42 100644 --- a/Samples/SpinningCube/SpinningCube.cpp +++ b/Samples/SpinningCube/SpinningCube.cpp @@ -70,42 +70,42 @@ namespace CGL { Graphics::VertexTypes::PositionColor { - .Position = SM::Vector3(-1.0f, 1.0f, -1.0f), + .Position = SM::Vector4(-1.0f, 1.0f, -1.0f, 1.0f), .Color = SM::Vector4(1.0f, 0.0f, 0.0f, 1.0f), }, Graphics::VertexTypes::PositionColor { - .Position = SM::Vector3(1.0f, 1.0f, -1.0f), + .Position = SM::Vector4(1.0f, 1.0f, -1.0f, 1.0f), .Color = SM::Vector4(0.0f, 1.0f, 0.0f, 1.0f), }, Graphics::VertexTypes::PositionColor { - .Position = SM::Vector3(1.0f, 1.0f, 1.0f), + .Position = SM::Vector4(1.0f, 1.0f, 1.0f, 1.0f), .Color = SM::Vector4(0.0f, 0.0f, 1.0f, 1.0f), }, Graphics::VertexTypes::PositionColor { - .Position = SM::Vector3(-1.0f, 1.0f, 1.0f), + .Position = SM::Vector4(-1.0f, 1.0f, 1.0f, 1.0f), .Color = SM::Vector4(1.0f, 1.0f, 0.0f, 1.0f), }, Graphics::VertexTypes::PositionColor { - .Position = SM::Vector3(-1.0f, -1.0f, -1.0f), + .Position = SM::Vector4(-1.0f, -1.0f, -1.0f, 1.0f), .Color = SM::Vector4(1.0f, 0.0f, 1.0f, 1.0f), }, Graphics::VertexTypes::PositionColor { - .Position = SM::Vector3(1.0f, -1.0f, -1.0f), + .Position = SM::Vector4(1.0f, -1.0f, -1.0f, 1.0f), .Color = SM::Vector4(0.0f, 1.0f, 1.0f, 1.0f), }, Graphics::VertexTypes::PositionColor { - .Position = SM::Vector3(1.0f, -1.0f, 1.0f), + .Position = SM::Vector4(1.0f, -1.0f, 1.0f, 1.0f), .Color = SM::Vector4(1.0f, 0.5f, 0.0f, 1.0f), }, Graphics::VertexTypes::PositionColor { - .Position = SM::Vector3(-1.0f, -1.0f, 1.0f), + .Position = SM::Vector4(-1.0f, -1.0f, 1.0f, 1.0f), .Color = SM::Vector4(0.5f, 0.0f, 0.5f, 1.0f), }, }; diff --git a/xmake.lua b/xmake.lua index 0b0fed2..9f3e2bd 100644 --- a/xmake.lua +++ b/xmake.lua @@ -10,7 +10,7 @@ set_languages("c17", "cxx23") set_defaultmode("debug") -- Project name and version -set_project("CrossGLVisualizer") +set_project("CrossVL") set_version("0.0.1") -- Enable all warnings and handle them as compilation errors