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