conversion to arena, missing get asset filename
This commit is contained in:
@@ -14,7 +14,7 @@ namespace Juliet
|
||||
|
||||
// Builds a full path to an asset file given its filename (e.g. "Triangle.vert.dxil").
|
||||
// The caller owns the returned buffer and must free it.
|
||||
[[nodiscard]] extern JULIET_API String GetAssetPath(String filename);
|
||||
[[nodiscard]] extern JULIET_API String GetAssetPath(NonNullPtr<Arena> arena, String filename);
|
||||
|
||||
[[nodiscard]]extern JULIET_API bool IsAbsolutePath(String path);
|
||||
[[nodiscard]] extern JULIET_API bool IsAbsolutePath(String path);
|
||||
} // namespace Juliet
|
||||
|
||||
@@ -36,17 +36,14 @@ namespace Juliet
|
||||
return CachedAssetBasePath;
|
||||
}
|
||||
|
||||
[[nodiscard]] String GetAssetPath(String filename)
|
||||
[[nodiscard]] String GetAssetPath(NonNullPtr<Arena> arena, String filename)
|
||||
{
|
||||
Assert(IsValid(CachedAssetBasePath));
|
||||
Assert(IsValid(filename));
|
||||
|
||||
size_t totalSize = CachedAssetBasePath.Size + filename.Size + 1;
|
||||
auto* buffer = static_cast<char*>(Calloc(totalSize, sizeof(char)));
|
||||
if (!buffer)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
char* buffer = ArenaPushArray<char>(arena, totalSize);
|
||||
Assert(buffer);
|
||||
|
||||
juliet_snprintf(buffer, totalSize, "%s%s", CStr(CachedAssetBasePath), CStr(filename));
|
||||
return { buffer, totalSize - 1 };
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#include <Graphics/DebugDisplay.h>
|
||||
|
||||
#include <Core/HAL/Filesystem/Filesystem.h>
|
||||
#include <Core/Logging/LogManager.h>
|
||||
#include <Core/Logging/LogTypes.h>
|
||||
#include <Core/HAL/Filesystem/Filesystem.h>
|
||||
#include <Core/Memory/Allocator.h>
|
||||
#include <Core/Thread/ThreadContext.h>
|
||||
#include <Graphics/GraphicsPipeline.h>
|
||||
#include <Graphics/PushConstants.h>
|
||||
|
||||
@@ -86,14 +87,18 @@ namespace Juliet
|
||||
ShaderCreateInfo shaderCI = {};
|
||||
shaderCI.EntryPoint = entryPoint;
|
||||
|
||||
String vertPath = GetAssetPath(WrapString("Debug.vert.dxil"));
|
||||
TempArena path = scratch_begin(0, 0);
|
||||
|
||||
String vertPath = GetAssetPath(path.Arena, WrapString("Debug.vert.dxil"));
|
||||
shaderCI.Stage = ShaderStage::Vertex;
|
||||
Shader* vertexShader = CreateShader(device, vertPath, shaderCI);
|
||||
|
||||
String fragPath = GetAssetPath(WrapString("Debug.frag.dxil"));
|
||||
String fragPath = GetAssetPath(path.Arena, WrapString("Debug.frag.dxil"));
|
||||
shaderCI.Stage = ShaderStage::Fragment;
|
||||
Shader* fragmentShader = CreateShader(device, fragPath, shaderCI);
|
||||
|
||||
scratch_end(path);
|
||||
|
||||
if (!vertexShader || !fragmentShader)
|
||||
{
|
||||
LogError(LogCategory::Graphics, "Failed to create debug shaders");
|
||||
@@ -310,12 +315,14 @@ namespace Juliet
|
||||
pushData.BufferIndex = bufferIndex;
|
||||
pushData.TextureIndex = 0;
|
||||
pushData.VertexOffset = 0; // Depth-tested vertices start at 0
|
||||
pushData.Scale[0] = 1.0f; pushData.Scale[1] = 1.0f;
|
||||
pushData.Translate[0] = 0.0f; pushData.Translate[1] = 0.0f;
|
||||
pushData.Scale[0] = 1.0f;
|
||||
pushData.Scale[1] = 1.0f;
|
||||
pushData.Translate[0] = 0.0f;
|
||||
pushData.Translate[1] = 0.0f;
|
||||
|
||||
// Dummy light data as we don't light debug primitives
|
||||
pushData.GlobalLightDirection = {0,0,-1};
|
||||
pushData.GlobalLightColor = {1,1,1};
|
||||
pushData.GlobalLightDirection = { 0, 0, -1 };
|
||||
pushData.GlobalLightColor = { 1, 1, 1 };
|
||||
pushData.GlobalAmbientIntensity = 1.0f;
|
||||
|
||||
SetPushConstants(cmdList, ShaderStage::Vertex, 0, sizeof(pushData) / sizeof(uint32), &pushData);
|
||||
@@ -336,12 +343,14 @@ namespace Juliet
|
||||
pushData.BufferIndex = bufferIndex;
|
||||
pushData.TextureIndex = 0;
|
||||
pushData.VertexOffset = kMaxDebugVertices / 2; // Overlay vertices start at half
|
||||
pushData.Scale[0] = 1.0f; pushData.Scale[1] = 1.0f;
|
||||
pushData.Translate[0] = 0.0f; pushData.Translate[1] = 0.0f;
|
||||
pushData.Scale[0] = 1.0f;
|
||||
pushData.Scale[1] = 1.0f;
|
||||
pushData.Translate[0] = 0.0f;
|
||||
pushData.Translate[1] = 0.0f;
|
||||
|
||||
// Dummy light data as we don't light debug primitives
|
||||
pushData.GlobalLightDirection = {0,0,-1};
|
||||
pushData.GlobalLightColor = {1,1,1};
|
||||
pushData.GlobalLightDirection = { 0, 0, -1 };
|
||||
pushData.GlobalLightColor = { 1, 1, 1 };
|
||||
pushData.GlobalAmbientIntensity = 1.0f;
|
||||
|
||||
SetPushConstants(cmdList, ShaderStage::Vertex, 0, sizeof(pushData) / sizeof(uint32), &pushData);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <Core/Logging/LogManager.h>
|
||||
#include <Core/Logging/LogTypes.h>
|
||||
#include <Core/Memory/MemoryArena.h>
|
||||
#include <Core/Thread/ThreadContext.h>
|
||||
#include <Graphics/GraphicsPipeline.h>
|
||||
#include <Graphics/PushConstants.h>
|
||||
#include <imgui.h>
|
||||
@@ -130,14 +131,18 @@ namespace Juliet
|
||||
ShaderCreateInfo shaderCI = {};
|
||||
shaderCI.EntryPoint = entryPoint;
|
||||
|
||||
String vertPath = GetAssetPath(WrapString("ImGui.vert.dxil"));
|
||||
TempArena path = scratch_begin(0, 0);
|
||||
|
||||
String vertPath = GetAssetPath(path.Arena, WrapString("ImGui.vert.dxil"));
|
||||
shaderCI.Stage = ShaderStage::Vertex;
|
||||
g_ImGuiState.VertexShader = CreateShader(device, vertPath, shaderCI);
|
||||
|
||||
String fragPath = GetAssetPath(WrapString("ImGui.frag.dxil"));
|
||||
String fragPath = GetAssetPath(path.Arena, WrapString("ImGui.frag.dxil"));
|
||||
shaderCI.Stage = ShaderStage::Fragment;
|
||||
g_ImGuiState.FragmentShader = CreateShader(device, fragPath, shaderCI);
|
||||
|
||||
scratch_end(path);
|
||||
|
||||
if (!g_ImGuiState.VertexShader || !g_ImGuiState.FragmentShader)
|
||||
{
|
||||
LogError(LogCategory::Graphics, "Failed to load ImGui shaders");
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <Core/Logging/LogManager.h>
|
||||
#include <Core/Logging/LogTypes.h>
|
||||
#include <Core/Math/Matrix.h>
|
||||
#include <Core/Thread/ThreadContext.h>
|
||||
#include <Engine/Asset.h>
|
||||
#include <Graphics/GraphicsDevice.h>
|
||||
#include <Graphics/Mesh.h>
|
||||
@@ -80,14 +81,18 @@ namespace Juliet
|
||||
ShaderCreateInfo shaderCI = {};
|
||||
shaderCI.EntryPoint = entryPoint;
|
||||
|
||||
String shaderPath = GetAssetPath(WrapString("Triangle.vert.dxil"));
|
||||
TempArena path = scratch_begin(0, 0);
|
||||
|
||||
String shaderPath = GetAssetPath(path.Arena, WrapString("Triangle.vert.dxil"));
|
||||
shaderCI.Stage = ShaderStage::Vertex;
|
||||
Shader* vertexShader = CreateShader(graphicsDevice, shaderPath, shaderCI);
|
||||
|
||||
shaderPath = GetAssetPath(WrapString("SolidColor.frag.dxil"));
|
||||
shaderPath = GetAssetPath(path.Arena, WrapString("SolidColor.frag.dxil"));
|
||||
shaderCI.Stage = ShaderStage::Fragment;
|
||||
Shader* fragmentShader = CreateShader(graphicsDevice, shaderPath, shaderCI);
|
||||
|
||||
scratch_end(path);
|
||||
|
||||
ColorTargetDescription colorTargetDescription = {};
|
||||
colorTargetDescription.Format = GetSwapChainTextureFormat(graphicsDevice, window);
|
||||
|
||||
@@ -543,17 +548,21 @@ namespace Juliet
|
||||
auto* pipeline = g_MeshRenderer.Pipeline;
|
||||
auto* device = g_MeshRenderer.Device;
|
||||
|
||||
TempArena path = scratch_begin(0, 0);
|
||||
|
||||
String entryPoint = WrapString("main");
|
||||
ShaderCreateInfo shaderCI = {};
|
||||
shaderCI.EntryPoint = entryPoint;
|
||||
String shaderPath = GetAssetPath(WrapString("Triangle.vert.dxil"));
|
||||
String shaderPath = GetAssetPath(path.Arena, WrapString("Triangle.vert.dxil"));
|
||||
shaderCI.Stage = ShaderStage::Vertex;
|
||||
Shader* vertexShader = CreateShader(device, shaderPath, shaderCI);
|
||||
|
||||
shaderPath = GetAssetPath(WrapString("SolidColor.frag.dxil"));
|
||||
shaderPath = GetAssetPath(path.Arena, WrapString("SolidColor.frag.dxil"));
|
||||
shaderCI.Stage = ShaderStage::Fragment;
|
||||
Shader* fragmentShader = CreateShader(device, shaderPath, shaderCI);
|
||||
|
||||
scratch_end(path);
|
||||
|
||||
UpdateGraphicsPipelineShaders(device, pipeline, vertexShader, fragmentShader);
|
||||
|
||||
if (vertexShader)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <Core/HAL/Filesystem/Filesystem.h>
|
||||
#include <Core/Logging/LogManager.h>
|
||||
#include <Core/Logging/LogTypes.h>
|
||||
#include <Core/Thread/ThreadContext.h>
|
||||
#include <Graphics/GraphicsDevice.h>
|
||||
#include <Graphics/PushConstants.h>
|
||||
|
||||
@@ -19,20 +20,24 @@ namespace Juliet
|
||||
|
||||
GraphicsDevice* graphicsDevice = g_SkyboxRenderer.Device = device.Get();
|
||||
|
||||
TempArena path = scratch_begin(0, 0);
|
||||
|
||||
String skyboxVSEntry = WrapString("main");
|
||||
ShaderCreateInfo skyboxVSCI = {};
|
||||
skyboxVSCI.EntryPoint = skyboxVSEntry;
|
||||
skyboxVSCI.Stage = ShaderStage::Vertex;
|
||||
String vsPath = GetAssetPath(WrapString("Skybox.vert.dxil"));
|
||||
String vsPath = GetAssetPath(path.Arena, WrapString("Skybox.vert.dxil"));
|
||||
Shader* skyboxVS = CreateShader(graphicsDevice, vsPath, skyboxVSCI);
|
||||
|
||||
String skyboxFSEntry = WrapString("main");
|
||||
ShaderCreateInfo skyboxFSCI = {};
|
||||
skyboxFSCI.EntryPoint = skyboxFSEntry;
|
||||
skyboxFSCI.Stage = ShaderStage::Fragment;
|
||||
String fsPath = GetAssetPath(WrapString("Skybox.frag.dxil"));
|
||||
String fsPath = GetAssetPath(path.Arena, WrapString("Skybox.frag.dxil"));
|
||||
Shader* skyboxFS = CreateShader(graphicsDevice, fsPath, skyboxFSCI);
|
||||
|
||||
scratch_end(path);
|
||||
|
||||
ColorTargetDescription colorTargetDesc = {};
|
||||
colorTargetDesc.Format = GetSwapChainTextureFormat(graphicsDevice, window);
|
||||
|
||||
@@ -58,8 +63,14 @@ namespace Juliet
|
||||
result = false;
|
||||
}
|
||||
|
||||
if (skyboxVS) DestroyShader(graphicsDevice, skyboxVS);
|
||||
if (skyboxFS) DestroyShader(graphicsDevice, skyboxFS);
|
||||
if (skyboxVS)
|
||||
{
|
||||
DestroyShader(graphicsDevice, skyboxVS);
|
||||
}
|
||||
if (skyboxFS)
|
||||
{
|
||||
DestroyShader(graphicsDevice, skyboxFS);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user