Shaders are not compiling anymore...

This commit is contained in:
Dynamitos
2023-12-02 10:55:00 +01:00
parent 9114a6f252
commit 6c156d3bc2
23 changed files with 190 additions and 148 deletions
+1 -1
+1 -2
View File
@@ -17,10 +17,9 @@ ParameterBlock<LightCullingData> pLightCullingData;
[shader("pixel")] [shader("pixel")]
float4 fragmentMain(in FragmentParameter params) : SV_Target float4 fragmentMain(in FragmentParameter params) : SV_Target
{ {
MaterialParameter materialParams = params.getMaterialParameter();
LightingParameter lightingParams = params.getLightingParameter(); LightingParameter lightingParams = params.getLightingParameter();
let brdf = pMaterial.prepare(materialParams); let brdf = pMaterial.prepare(params.getMaterialParameter());
float3 result = float3(0, 0, 0); float3 result = float3(0, 0, 0);
for(int i = 0; i < pLightEnv.numDirectionalLights; ++i) for(int i = 0; i < pLightEnv.numDirectionalLights; ++i)
{ {
+1 -1
View File
@@ -30,7 +30,7 @@ struct BlinnPhong : IBRDF
float3 h = lightDir_WS + viewDir_WS; float3 h = lightDir_WS + viewDir_WS;
float specular = dot(normal_WS, h); float specular = dot(normal_WS, h);
return lightDir_WS * 2 + float3(1, 1, 1);//baseColor * (diffuse + specular) * lightColor; return baseColor * (diffuse + specular) * lightColor;
} }
}; };
+4 -3
View File
@@ -35,14 +35,15 @@ struct Frustum
Plane basePlane; Plane basePlane;
bool pointInside(float3 point) bool pointInside(float3 point)
{ {
if (dot(basePlane.n, point) + basePlane.d < 0) float result = dot(basePlane.n, point) + basePlane.d;
if (0.0f > result)
{ {
return false; return false;
} }
for(int p = 0; p < 4; ++p) for(int p = 0; p < 4; ++p)
{ {
float result = dot(sides[p].n, point) + sides[p].d; result = dot(sides[p].n, point) + sides[p].d;
if(result < 0) if(0.0f > result)
{ {
return false; return false;
} }
+1 -1
View File
@@ -28,7 +28,7 @@ struct PointLight : ILightEnv
float3 lightDir_WS = position_WS.xyz - params.position_WS; float3 lightDir_WS = position_WS.xyz - params.position_WS;
float d = length(lightDir_WS); float d = length(lightDir_WS);
float illuminance = max(1 - d / colorRange.w, 0); float illuminance = max(1 - d / colorRange.w, 0);
return brdf.evaluate(params.tbn, params.viewDir_WS, normalize(lightDir_WS), colorRange.xyz); return illuminance * brdf.evaluate(params.tbn, params.viewDir_WS, normalize(lightDir_WS), colorRange.xyz);
} }
bool insidePlane(Plane plane) bool insidePlane(Plane plane)
+25 -6
View File
@@ -48,23 +48,40 @@ void MeshLoader::loadMaterials(const aiScene* scene, const std::string& baseName
{ {
aiMaterial* material = scene->mMaterials[i]; aiMaterial* material = scene->mMaterials[i];
json matCode; json matCode;
std::string materialName = std::format("{0}{1}", baseName, material->GetName().C_Str()); std::string materialName = std::format("{0}{1}{2}", baseName, material->GetName().C_Str(), char(i+'a'));
materialName.erase(std::remove(materialName.begin(), materialName.end(), '.'), materialName.end()); // dots break adding the .asset extension later materialName.erase(std::remove(materialName.begin(), materialName.end(), '.'), materialName.end()); // dots break adding the .asset extension later
matCode["name"] = materialName; matCode["name"] = materialName;
matCode["profile"] = "BlinnPhong"; //TODO: other shading models matCode["profile"] = "BlinnPhong"; //TODO: other shading models
aiString texPath; aiString texPath;
//TODO make samplers based on used textures
if(material->GetTexture(aiTextureType_DIFFUSE, 0, &texPath) == AI_SUCCESS) if(material->GetTexture(aiTextureType_DIFFUSE, 0, &texPath) == AI_SUCCESS)
{ {
std::string texFilename = std::filesystem::path(texPath.C_Str()).stem().string(); auto texFilename = std::filesystem::path(texPath.C_Str()).stem();
if (texFilename == "white")
{
matCode["code"].push_back(
{
{ "exp", "BRDF" },
{ "profile", "BlinnPhong" },
{ "values", {
{"baseColor", "float3(1, 1, 1)"}
}}
}
);
}
else
{
AssetImporter::importTexture(TextureImportArgs{
.filePath = meshDirectory / texPath.C_Str(),
.importPath = importPath,
});
matCode["params"]["diffuseTexture"] = matCode["params"]["diffuseTexture"] =
{ {
{"type", "Texture2D"}, {"type", "Texture2D"},
{"default", texFilename} {"default", texFilename.string()}
}; };
matCode["params"]["diffuseSampler"] = matCode["params"]["diffuseSampler"] =
{ {
{"type", "SamplerState"} {"type", "Sampler"}
}; };
matCode["code"].push_back( matCode["code"].push_back(
{ {
@@ -91,6 +108,8 @@ void MeshLoader::loadMaterials(const aiScene* scene, const std::string& baseName
} }
); );
} }
}
else else
{ {
matCode["code"].push_back( matCode["code"].push_back(
@@ -109,7 +128,7 @@ void MeshLoader::loadMaterials(const aiScene* scene, const std::string& baseName
if(material->GetTexture(aiTextureType_NORMALS, 0, &texPath) == AI_SUCCESS) if(material->GetTexture(aiTextureType_NORMALS, 0, &texPath) == AI_SUCCESS)
{ {
} }
std::string outMatFilename = matCode["name"].get<std::string>().append(".json"); std::string outMatFilename = materialName.append(".json");
std::ofstream outMatFile = std::ofstream(meshDirectory / outMatFilename); std::ofstream outMatFile = std::ofstream(meshDirectory / outMatFilename);
outMatFile << std::setw(4) << matCode; outMatFile << std::setw(4) << matCode;
outMatFile.flush(); outMatFile.flush();
+12 -2
View File
@@ -58,6 +58,9 @@ int main()
AssetImporter::importMesh(MeshImportArgs{ AssetImporter::importMesh(MeshImportArgs{
.filePath= sourcePath / "old_resources/models/cube.fbx", .filePath= sourcePath / "old_resources/models/cube.fbx",
}); });
AssetImporter::importMesh(MeshImportArgs{
.filePath = sourcePath / "old_resources/models/sponza/sponza.gltf",
});
//AssetImporter::importMesh(MeshImportArgs{ //AssetImporter::importMesh(MeshImportArgs{
// .filePath= sourcePath / "old_resources/models/flameThrower.fbx", // .filePath= sourcePath / "old_resources/models/flameThrower.fbx",
// }); // });
@@ -238,9 +241,15 @@ int main()
//window->addView(inspectorView); //window->addView(inspectorView);
sceneView->setFocused(); sceneView->setFocused();
window->render();
//export game
while (windowManager->isActive())
{
windowManager->render();
}
vd->~StaticMeshVertexData();
//export game
if (false)
{
std::filesystem::create_directories(outputPath); std::filesystem::create_directories(outputPath);
std::system(std::format("cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGAME_TITLE=\"{}\" -DGAME_DESTINATION=\"{}\" -DGAME_BINARY=\"{}\" -P ./cmake/ExportProject.cmake", gameName, outputPath.generic_string(), binaryPath.generic_string()).c_str()); std::system(std::format("cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGAME_TITLE=\"{}\" -DGAME_DESTINATION=\"{}\" -DGAME_BINARY=\"{}\" -P ./cmake/ExportProject.cmake", gameName, outputPath.generic_string(), binaryPath.generic_string()).c_str());
std::system(std::format("cmake -S {} -B {}", cmakePath.generic_string(), cmakePath.generic_string()).c_str()); std::system(std::format("cmake -S {} -B {}", cmakePath.generic_string(), cmakePath.generic_string()).c_str());
@@ -254,5 +263,6 @@ int main()
std::filesystem::copy_file("slang-glslang.dll", outputPath / "slang-glslang.dll"); std::filesystem::copy_file("slang-glslang.dll", outputPath / "slang-glslang.dll");
std::filesystem::copy_file("slang-llvm.dll", outputPath / "slang-llvm.dll"); std::filesystem::copy_file("slang-llvm.dll", outputPath / "slang-llvm.dll");
#endif #endif
}
return 0; return 0;
} }
+7 -34
View File
@@ -3,34 +3,6 @@
using namespace Seele; using namespace Seele;
using namespace Seele::Gfx; using namespace Seele::Gfx;
DescriptorBinding::DescriptorBinding()
: binding(0)
, descriptorType(SE_DESCRIPTOR_TYPE_MAX_ENUM)
, descriptorCount(0x7fff)
, shaderStages(SE_SHADER_STAGE_ALL)
{
}
DescriptorBinding::DescriptorBinding(const DescriptorBinding& other)
: binding(other.binding)
, descriptorType(other.descriptorType)
, descriptorCount(other.descriptorCount)
, shaderStages(other.shaderStages)
{
}
DescriptorBinding& DescriptorBinding::operator=(const DescriptorBinding& other)
{
if (this != &other)
{
binding = other.binding;
descriptorType = other.descriptorType;
descriptorCount = other.descriptorCount;
shaderStages = other.shaderStages;
}
return *this;
}
DescriptorPool::DescriptorPool() DescriptorPool::DescriptorPool()
{ {
} }
@@ -77,12 +49,13 @@ void DescriptorLayout::addDescriptorBinding(uint32 bindingIndex, SeDescriptorTyp
{ {
descriptorBindings.resize(bindingIndex + 1); descriptorBindings.resize(bindingIndex + 1);
} }
DescriptorBinding& binding = descriptorBindings[bindingIndex]; descriptorBindings[bindingIndex] = DescriptorBinding{
binding.binding = bindingIndex; .binding = bindingIndex,
binding.descriptorType = type; .descriptorType = type,
binding.descriptorCount = arrayCount; .descriptorCount = arrayCount,
binding.bindingFlags = bindingFlags; .bindingFlags = bindingFlags,
binding.shaderStages = shaderStages; .shaderStages = shaderStages,
};
} }
PDescriptorSet DescriptorLayout::allocateDescriptorSet() PDescriptorSet DescriptorLayout::allocateDescriptorSet()
+5 -9
View File
@@ -6,17 +6,13 @@ namespace Seele
{ {
namespace Gfx namespace Gfx
{ {
class DescriptorBinding struct DescriptorBinding
{ {
public: uint32 binding = 0;
DescriptorBinding(); SeDescriptorType descriptorType = SE_DESCRIPTOR_TYPE_MAX_ENUM;
DescriptorBinding(const DescriptorBinding& other); uint32 descriptorCount = 0x7fff;
DescriptorBinding& operator=(const DescriptorBinding& other);
uint32 binding;
SeDescriptorType descriptorType;
uint32 descriptorCount;
SeDescriptorBindingFlags bindingFlags = 0; SeDescriptorBindingFlags bindingFlags = 0;
SeShaderStageFlags shaderStages; SeShaderStageFlags shaderStages = SE_SHADER_STAGE_ALL;
}; };
DEFINE_REF(DescriptorBinding) DEFINE_REF(DescriptorBinding)
-1
View File
@@ -1,6 +1,5 @@
#include "Graphics.h" #include "Graphics.h"
#include "Shader.h" #include "Shader.h"
#include "Graphics.h"
using namespace Seele::Gfx; using namespace Seele::Gfx;
+1 -11
View File
@@ -66,7 +66,6 @@ Allocation::Allocation(PGraphics graphics, PAllocator pool, VkDeviceSize size, u
Allocation::~Allocation() Allocation::~Allocation()
{ {
vkFreeMemory(device, allocatedMemory, nullptr); vkFreeMemory(device, allocatedMemory, nullptr);
assert(bytesUsed == 0);
} }
OSubAllocation Allocation::getSuballocation(VkDeviceSize requestedSize, VkDeviceSize alignment) OSubAllocation Allocation::getSuballocation(VkDeviceSize requestedSize, VkDeviceSize alignment)
@@ -177,16 +176,6 @@ Allocator::Allocator(PGraphics graphics)
Allocator::~Allocator() Allocator::~Allocator()
{ {
for (auto& heap : heaps)
{
for (auto& alloc : heap.allocations)
{
assert(alloc->activeAllocations.empty());
assert(alloc->freeRanges.size() == 1);
}
heap.allocations.clear();
}
graphics = nullptr;
} }
OSubAllocation Allocator::allocate(const VkMemoryRequirements2 &memRequirements2, VkMemoryPropertyFlags properties, VkMemoryDedicatedAllocateInfo *dedicatedInfo) OSubAllocation Allocator::allocate(const VkMemoryRequirements2 &memRequirements2, VkMemoryPropertyFlags properties, VkMemoryDedicatedAllocateInfo *dedicatedInfo)
@@ -272,6 +261,7 @@ StagingBuffer::~StagingBuffer()
graphics->getDedicatedTransferCommands()->getCommands(), buffer); graphics->getDedicatedTransferCommands()->getCommands(), buffer);
graphics->getDestructionManager()->queueAllocation( graphics->getDestructionManager()->queueAllocation(
graphics->getDedicatedTransferCommands()->getCommands(), std::move(allocation)); graphics->getDedicatedTransferCommands()->getCommands(), std::move(allocation));
graphics->getDedicatedTransferCommands()->submitCommands();
} }
void* StagingBuffer::map() void* StagingBuffer::map()
+4
View File
@@ -469,6 +469,10 @@ CommandPool::CommandPool(PGraphics graphics, PQueue queue)
CommandPool::~CommandPool() CommandPool::~CommandPool()
{ {
vkDeviceWaitIdle(graphics->getDevice()); vkDeviceWaitIdle(graphics->getDevice());
for (auto& command : allocatedBuffers)
{
command->checkFence();
}
allocatedRenderCommands.clear(); allocatedRenderCommands.clear();
allocatedComputeCommands.clear(); allocatedComputeCommands.clear();
allocatedBuffers.clear(); allocatedBuffers.clear();
+9 -2
View File
@@ -2,6 +2,7 @@
#include "Graphics.h" #include "Graphics.h"
#include "Texture.h" #include "Texture.h"
#include "Buffer.h" #include "Buffer.h"
#include "Command.h"
using namespace Seele; using namespace Seele;
using namespace Seele::Vulkan; using namespace Seele::Vulkan;
@@ -345,8 +346,14 @@ DescriptorPool::DescriptorPool(PGraphics graphics, DescriptorLayout &layout)
DescriptorPool::~DescriptorPool() DescriptorPool::~DescriptorPool()
{ {
vkDestroyDescriptorPool(graphics->getDevice(), poolHandle, nullptr); for (uint32 setIndex = 0; setIndex < cachedHandles.size(); ++setIndex)
graphics = nullptr; {
if (cachedHandles[setIndex] != nullptr && cachedHandles[setIndex]->setHandle != VK_NULL_HANDLE)
{
graphics->getDestructionManager()->queueDescriptorSet(graphics->getGraphicsCommands()->getCommands(), Pair<VkDescriptorSet, VkDescriptorPool>(cachedHandles[setIndex]->setHandle, poolHandle));
}
}
graphics->getDestructionManager()->queueDescriptorPool(graphics->getGraphicsCommands()->getCommands(), poolHandle);
if(nextAlloc) if(nextAlloc)
{ {
delete nextAlloc; delete nextAlloc;
+11
View File
@@ -32,6 +32,17 @@ Graphics::Graphics()
Graphics::~Graphics() Graphics::~Graphics()
{ {
vkDeviceWaitIdle(handle);
graphicsCommands = nullptr;
computeCommands = nullptr;
transferCommands = nullptr;
dedicatedTransferCommands = nullptr;
pipelineCache = nullptr;
allocator = nullptr;
destructionManager = nullptr;
stagingManager = nullptr;
allocatedFramebuffers.clear();
shaderCompiler = nullptr;
vkDestroyDevice(handle, nullptr); vkDestroyDevice(handle, nullptr);
DestroyDebugReportCallbackEXT(instance, nullptr, callback); DestroyDebugReportCallbackEXT(instance, nullptr, callback);
vkDestroyInstance(instance, nullptr); vkDestroyInstance(instance, nullptr);
+1 -1
View File
@@ -85,7 +85,6 @@ protected:
OQueue computeQueue; OQueue computeQueue;
OQueue transferQueue; OQueue transferQueue;
OQueue dedicatedTransferQueue; OQueue dedicatedTransferQueue;
OPipelineCache pipelineCache;
thread_local static OCommandPool graphicsCommands; thread_local static OCommandPool graphicsCommands;
thread_local static OCommandPool computeCommands; thread_local static OCommandPool computeCommands;
thread_local static OCommandPool transferCommands; thread_local static OCommandPool transferCommands;
@@ -96,6 +95,7 @@ protected:
VkDebugReportCallbackEXT callback; VkDebugReportCallbackEXT callback;
Map<uint32, OFramebuffer> allocatedFramebuffers; Map<uint32, OFramebuffer> allocatedFramebuffers;
OAllocator allocator; OAllocator allocator;
OPipelineCache pipelineCache;
OStagingManager stagingManager; OStagingManager stagingManager;
ODestructionManager destructionManager; ODestructionManager destructionManager;
+2 -2
View File
@@ -37,9 +37,9 @@ PipelineCache::PipelineCache(PGraphics graphics, const std::string& cacheFilePat
PipelineCache::~PipelineCache() PipelineCache::~PipelineCache()
{ {
VkDeviceSize cacheSize; VkDeviceSize cacheSize;
vkGetPipelineCacheData(graphics->getDevice(), cache, &cacheSize, nullptr); VK_CHECK(vkGetPipelineCacheData(graphics->getDevice(), cache, &cacheSize, nullptr));
Array<uint8> cacheData(cacheSize); Array<uint8> cacheData(cacheSize);
vkGetPipelineCacheData(graphics->getDevice(), cache, &cacheSize, cacheData.data()); VK_CHECK(vkGetPipelineCacheData(graphics->getDevice(), cache, &cacheSize, cacheData.data()));
std::ofstream stream(cacheFile, std::ios::binary); std::ofstream stream(cacheFile, std::ios::binary);
stream.write((char*)cacheData.data(), cacheSize); stream.write((char*)cacheData.data(), cacheSize);
stream.flush(); stream.flush();
+3 -2
View File
@@ -2,7 +2,8 @@
#include "Graphics.h" #include "Graphics.h"
#include "Framebuffer.h" #include "Framebuffer.h"
#include "Texture.h" #include "Texture.h"
#include "RenderPass.h" #include "Resources.h"
#include "Command.h"
using namespace Seele; using namespace Seele;
using namespace Seele::Vulkan; using namespace Seele::Vulkan;
@@ -125,7 +126,7 @@ RenderPass::RenderPass(PGraphics graphics, Gfx::ORenderTargetLayout _layout, Gfx
RenderPass::~RenderPass() RenderPass::~RenderPass()
{ {
vkDestroyRenderPass(graphics->getDevice(), renderPass, nullptr); graphics->getDestructionManager()->queueRenderPass(graphics->getGraphicsCommands()->getCommands(), renderPass);
} }
uint32 RenderPass::getFramebufferHash() uint32 RenderPass::getFramebufferHash()
+29 -1
View File
@@ -20,7 +20,7 @@ Semaphore::Semaphore(PGraphics graphics)
Semaphore::~Semaphore() Semaphore::~Semaphore()
{ {
graphics->getDestructionManager()->queueSemaphore(graphics->getGraphicsCommands()->getCommands(), handle); vkDestroySemaphore(graphics->getDevice(), handle, nullptr);
} }
Fence::Fence(PGraphics graphics) Fence::Fence(PGraphics graphics)
@@ -114,6 +114,21 @@ void DestructionManager::queueSemaphore(PCommand cmd, VkSemaphore sem)
sems[cmd].add(sem); sems[cmd].add(sem);
} }
void DestructionManager::queueRenderPass(PCommand cmd, VkRenderPass renderPass)
{
renderPasses[cmd].add(renderPass);
}
void DestructionManager::queueDescriptorPool(PCommand cmd, VkDescriptorPool pool)
{
pools[cmd].add(pool);
}
void DestructionManager::queueDescriptorSet(PCommand cmd, Pair<VkDescriptorSet, VkDescriptorPool> set)
{
sets[cmd].add(set);
}
void DestructionManager::queueAllocation(PCommand cmd, OSubAllocation alloc) void DestructionManager::queueAllocation(PCommand cmd, OSubAllocation alloc)
{ {
allocs[cmd].add(std::move(alloc)); allocs[cmd].add(std::move(alloc));
@@ -137,9 +152,22 @@ void DestructionManager::notifyCmdComplete(PCommand cmd)
{ {
vkDestroySemaphore(graphics->getDevice(), sem, nullptr); vkDestroySemaphore(graphics->getDevice(), sem, nullptr);
} }
for (auto [set, pool] : sets[cmd])
{
vkFreeDescriptorSets(graphics->getDevice(), pool, 1, &set);
}
for (auto pool : pools[cmd])
{
vkDestroyDescriptorPool(graphics->getDevice(), pool, nullptr);
}
for (auto renderPass : renderPasses[cmd])
{
vkDestroyRenderPass(graphics->getDevice(), renderPass, nullptr);
}
buffers[cmd].clear(); buffers[cmd].clear();
images[cmd].clear(); images[cmd].clear();
views[cmd].clear(); views[cmd].clear();
sems[cmd].clear(); sems[cmd].clear();
renderPasses[cmd].clear();
allocs[cmd].clear(); allocs[cmd].clear();
} }
+6
View File
@@ -61,6 +61,9 @@ public:
void queueImage(PCommand cmd, VkImage image); void queueImage(PCommand cmd, VkImage image);
void queueImageView(PCommand cmd, VkImageView view); void queueImageView(PCommand cmd, VkImageView view);
void queueSemaphore(PCommand cmd, VkSemaphore sem); void queueSemaphore(PCommand cmd, VkSemaphore sem);
void queueRenderPass(PCommand cmd, VkRenderPass renderPass);
void queueDescriptorPool(PCommand cmd, VkDescriptorPool pool);
void queueDescriptorSet(PCommand cmd, Pair<VkDescriptorSet, VkDescriptorPool> set);
void queueAllocation(PCommand cmd, OSubAllocation alloc); void queueAllocation(PCommand cmd, OSubAllocation alloc);
void notifyCmdComplete(PCommand cmdbuffer); void notifyCmdComplete(PCommand cmdbuffer);
private: private:
@@ -69,6 +72,9 @@ private:
Map<PCommand, List<VkImage>> images; Map<PCommand, List<VkImage>> images;
Map<PCommand, List<VkImageView>> views; Map<PCommand, List<VkImageView>> views;
Map<PCommand, List<VkSemaphore>> sems; Map<PCommand, List<VkSemaphore>> sems;
Map<PCommand, List<VkRenderPass>> renderPasses;
Map<PCommand, List<VkDescriptorPool>> pools;
Map<PCommand, List<Pair<VkDescriptorSet, VkDescriptorPool>>> sets;
Map<PCommand, List<OSubAllocation>> allocs; Map<PCommand, List<OSubAllocation>> allocs;
}; };
DEFINE_REF(DestructionManager) DEFINE_REF(DestructionManager)
+4 -7
View File
@@ -55,12 +55,8 @@ void Shader::create(const ShaderCreateInfo& createInfo)
slang::TargetDesc vulkan; slang::TargetDesc vulkan;
vulkan.profile = globalSession->findProfile("sm_6_6"); vulkan.profile = globalSession->findProfile("sm_6_6");
vulkan.format = SLANG_SPIRV; vulkan.format = SLANG_SPIRV;
slang::TargetDesc glsl; sessionDesc.targetCount = 1;
glsl.profile = globalSession->findProfile("sm_6_6"); sessionDesc.targets = &vulkan;
glsl.format = SLANG_GLSL;
slang::TargetDesc targets[2] = { vulkan, glsl };
sessionDesc.targetCount = 2;
sessionDesc.targets = targets;
StaticArray<const char*, 3> searchPaths = {"shaders/", "shaders/lib/", "shaders/generated/"}; StaticArray<const char*, 3> searchPaths = {"shaders/", "shaders/lib/", "shaders/generated/"};
sessionDesc.searchPaths = searchPaths.data(); sessionDesc.searchPaths = searchPaths.data();
sessionDesc.searchPathCount = searchPaths.size(); sessionDesc.searchPathCount = searchPaths.size();
@@ -136,7 +132,7 @@ void Shader::create(const ShaderCreateInfo& createInfo)
hash = CRC::Calculate(entryPointName.data(), entryPointName.size(), CRC::CRC_32()); hash = CRC::Calculate(entryPointName.data(), entryPointName.size(), CRC::CRC_32());
hash = CRC::Calculate(kernelBlob->getBufferPointer(), kernelBlob->getBufferSize(), CRC::CRC_32(), hash); hash = CRC::Calculate(kernelBlob->getBufferPointer(), kernelBlob->getBufferSize(), CRC::CRC_32(), hash);
/*
specializedComponent->getEntryPointCode( specializedComponent->getEntryPointCode(
0, 0,
1, 1,
@@ -147,4 +143,5 @@ void Shader::create(const ShaderCreateInfo& createInfo)
std::ofstream shaderStream(createInfo.name + createInfo.entryPoint + ".glsl"); std::ofstream shaderStream(createInfo.name + createInfo.entryPoint + ".glsl");
shaderStream << (char*)kernelBlob->getBufferPointer(); shaderStream << (char*)kernelBlob->getBufferPointer();
shaderStream.close(); shaderStream.close();
*/
} }
-3
View File
@@ -22,8 +22,6 @@ void Window::addView(PView view)
void Window::render() void Window::render()
{ {
while(owner->isActive())
{
gfxHandle->beginFrame(); gfxHandle->beginFrame();
for(auto& view : views) for(auto& view : views)
{ {
@@ -34,7 +32,6 @@ void Window::render()
view->render(); view->render();
} }
gfxHandle->endFrame(); gfxHandle->endFrame();
}
} }
Gfx::PWindow Window::getGfxHandle() Gfx::PWindow Window::getGfxHandle()
+12 -9
View File
@@ -11,19 +11,22 @@ WindowManager::~WindowManager()
{ {
} }
PWindow WindowManager::addWindow(Gfx::PGraphics graphics, const WindowCreateInfo &createInfo) OWindow WindowManager::addWindow(Gfx::PGraphics graphics, const WindowCreateInfo &createInfo)
{ {
OWindow window = new Window(this, graphics->createWindow(createInfo)); OWindow window = new Window(this, graphics->createWindow(createInfo));
PWindow ref = window; windows.add(window);
windows.add(std::move(window)); return window;
return ref; }
void WindowManager::render()
{
for (auto& window : windows)
{
window->render();
}
} }
void WindowManager::notifyWindowClosed(PWindow window) void WindowManager::notifyWindowClosed(PWindow window)
{ {
windows.remove(windows.find([window] (const OWindow& w) { return window == w; })); windows.remove(window);
if(windows.empty())
{
exit(0);
}
} }
+4 -3
View File
@@ -10,15 +10,16 @@ class WindowManager
public: public:
WindowManager(); WindowManager();
~WindowManager(); ~WindowManager();
PWindow addWindow(Gfx::PGraphics graphics, const WindowCreateInfo &createInfo); OWindow addWindow(Gfx::PGraphics graphics, const WindowCreateInfo &createInfo);
void render();
void notifyWindowClosed(PWindow window); void notifyWindowClosed(PWindow window);
inline bool isActive() const bool isActive() const
{ {
return windows.size(); return windows.size();
} }
private: private:
Array<OWindow> windows; Array<PWindow> windows;
}; };
DEFINE_REF(WindowManager) DEFINE_REF(WindowManager)
} // namespace Seele } // namespace Seele