Actually fixing pipeline cache
This commit is contained in:
@@ -136,9 +136,9 @@ EnvironmentLoader::EnvironmentLoader(Gfx::PGraphics graphics) : graphics(graphic
|
|||||||
{Gfx::SubPassDependency{
|
{Gfx::SubPassDependency{
|
||||||
.srcSubpass = 0,
|
.srcSubpass = 0,
|
||||||
.dstSubpass = ~0U,
|
.dstSubpass = ~0U,
|
||||||
.srcStage = Gfx::SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
|
.srcStage = Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||||
.dstStage = Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
.dstStage = Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||||
.srcAccess = Gfx::SE_ACCESS_NONE,
|
.srcAccess = Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||||
.dstAccess = Gfx::SE_ACCESS_SHADER_READ_BIT,
|
.dstAccess = Gfx::SE_ACCESS_SHADER_READ_BIT,
|
||||||
}},
|
}},
|
||||||
URect{{512, 512}, {0, 0}}, "LUTGeneration");
|
URect{{512, 512}, {0, 0}}, "LUTGeneration");
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#include "PlayView.h"
|
#include "PlayView.h"
|
||||||
#include "Component/Mesh.h"
|
#include "Component/Mesh.h"
|
||||||
|
#include "Graphics/Enums.h"
|
||||||
|
#include "MinimalEngine.h"
|
||||||
#include "Window/Window.h"
|
#include "Window/Window.h"
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
@@ -34,6 +36,10 @@ void PlayView::keyCallback(KeyCode code, InputAction action, KeyModifier modifie
|
|||||||
getGlobals().useLightCulling = !getGlobals().useLightCulling;
|
getGlobals().useLightCulling = !getGlobals().useLightCulling;
|
||||||
std::cout << "Use Light Culling " << getGlobals().useLightCulling << std::endl;
|
std::cout << "Use Light Culling " << getGlobals().useLightCulling << std::endl;
|
||||||
}
|
}
|
||||||
|
if(code == KeyCode::KEY_K && action == InputAction::RELEASE) {
|
||||||
|
getGlobals().useImagebasedLighting = !getGlobals().useImagebasedLighting;
|
||||||
|
std::cout << "Use IBL " << getGlobals().useImagebasedLighting << std::endl;
|
||||||
|
}
|
||||||
if (code == KeyCode::KEY_G && action == InputAction::RELEASE) {
|
if (code == KeyCode::KEY_G && action == InputAction::RELEASE) {
|
||||||
Component::Camera cam;
|
Component::Camera cam;
|
||||||
Component::Transform tra;
|
Component::Transform tra;
|
||||||
|
|||||||
@@ -518,17 +518,12 @@ template <typename T, size_t N> struct StaticArray {
|
|||||||
using reverse_iterator = std::reverse_iterator<iterator>;
|
using reverse_iterator = std::reverse_iterator<iterator>;
|
||||||
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
||||||
|
|
||||||
constexpr StaticArray() {
|
constexpr StaticArray() {}
|
||||||
beginIt = iterator(_data);
|
|
||||||
endIt = iterator(_data + N);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr StaticArray(T value) {
|
constexpr StaticArray(T value) {
|
||||||
for (size_t i = 0; i < N; ++i) {
|
for (size_t i = 0; i < N; ++i) {
|
||||||
_data[i] = value;
|
_data[i] = value;
|
||||||
}
|
}
|
||||||
beginIt = iterator(_data);
|
|
||||||
endIt = iterator(_data + N);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr StaticArray(std::initializer_list<T> init) {
|
constexpr StaticArray(std::initializer_list<T> init) {
|
||||||
@@ -555,14 +550,12 @@ template <typename T, size_t N> struct StaticArray {
|
|||||||
assert(index < N);
|
assert(index < N);
|
||||||
return _data[index];
|
return _data[index];
|
||||||
}
|
}
|
||||||
constexpr iterator begin() { return beginIt; }
|
constexpr iterator begin() { return iterator(_data); }
|
||||||
constexpr iterator end() { return endIt; }
|
constexpr iterator end() { return iterator(_data + N); }
|
||||||
constexpr const_iterator begin() const { return beginIt; }
|
constexpr const_iterator begin() const { return iterator(_data); }
|
||||||
constexpr const_iterator end() const { return beginIt; }
|
constexpr const_iterator end() const { return iterator(_data + N); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T _data[N] = {T()};
|
T _data[N] = {T()};
|
||||||
iterator beginIt;
|
|
||||||
iterator endIt;
|
|
||||||
};
|
};
|
||||||
} // namespace Seele
|
} // namespace Seele
|
||||||
|
|||||||
@@ -45,11 +45,9 @@ PipelineCache::~PipelineCache() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PGraphicsPipeline PipelineCache::createPipeline(Gfx::LegacyPipelineCreateInfo gfxInfo) {
|
PGraphicsPipeline PipelineCache::createPipeline(Gfx::LegacyPipelineCreateInfo gfxInfo) {
|
||||||
uint32 hash = CRC::Calculate(&gfxInfo, sizeof(Gfx::LegacyPipelineCreateInfo), CRC::CRC_32());
|
PPipelineLayout layout = Gfx::PPipelineLayout(gfxInfo.pipelineLayout).cast<PipelineLayout>();
|
||||||
if (graphicsPipelines.contains(hash)) {
|
uint32 hash = layout->getHash();
|
||||||
return graphicsPipelines[hash];
|
|
||||||
}
|
|
||||||
PPipelineLayout layout = gfxInfo.pipelineLayout.cast<PipelineLayout>();
|
|
||||||
Array<VkVertexInputBindingDescription> bindings;
|
Array<VkVertexInputBindingDescription> bindings;
|
||||||
Array<VkVertexInputAttributeDescription> attributes;
|
Array<VkVertexInputAttributeDescription> attributes;
|
||||||
if (gfxInfo.vertexInput != nullptr) {
|
if (gfxInfo.vertexInput != nullptr) {
|
||||||
@@ -70,6 +68,9 @@ PGraphicsPipeline PipelineCache::createPipeline(Gfx::LegacyPipelineCreateInfo gf
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
hash = CRC::Calculate(bindings.data(), bindings.size() * sizeof(VkVertexInputBindingDescription), CRC::CRC_32(), hash);
|
||||||
|
hash = CRC::Calculate(attributes.data(), attributes.size() * sizeof(VkVertexInputAttributeDescription), CRC::CRC_32(), hash);
|
||||||
|
|
||||||
VkPipelineVertexInputStateCreateInfo vertexInput = {
|
VkPipelineVertexInputStateCreateInfo vertexInput = {
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
@@ -81,8 +82,7 @@ PGraphicsPipeline PipelineCache::createPipeline(Gfx::LegacyPipelineCreateInfo gf
|
|||||||
};
|
};
|
||||||
uint32 stageCount = 0;
|
uint32 stageCount = 0;
|
||||||
|
|
||||||
VkPipelineShaderStageCreateInfo stageInfos[2];
|
StaticArray<VkPipelineShaderStageCreateInfo, 2> stageInfos;
|
||||||
std::memset(stageInfos, 0, sizeof(stageInfos));
|
|
||||||
|
|
||||||
PVertexShader vertexShader = gfxInfo.vertexShader.cast<VertexShader>();
|
PVertexShader vertexShader = gfxInfo.vertexShader.cast<VertexShader>();
|
||||||
stageInfos[stageCount++] = {
|
stageInfos[stageCount++] = {
|
||||||
@@ -94,7 +94,7 @@ PGraphicsPipeline PipelineCache::createPipeline(Gfx::LegacyPipelineCreateInfo gf
|
|||||||
.pName = vertexShader->getEntryPointName(),
|
.pName = vertexShader->getEntryPointName(),
|
||||||
.pSpecializationInfo = nullptr,
|
.pSpecializationInfo = nullptr,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (gfxInfo.fragmentShader != nullptr) {
|
if (gfxInfo.fragmentShader != nullptr) {
|
||||||
PFragmentShader fragment = gfxInfo.fragmentShader.cast<FragmentShader>();
|
PFragmentShader fragment = gfxInfo.fragmentShader.cast<FragmentShader>();
|
||||||
|
|
||||||
@@ -108,6 +108,8 @@ PGraphicsPipeline PipelineCache::createPipeline(Gfx::LegacyPipelineCreateInfo gf
|
|||||||
.pSpecializationInfo = nullptr,
|
.pSpecializationInfo = nullptr,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
hash = CRC::Calculate(stageInfos.data(), stageInfos.size() * sizeof(VkVertexInputAttributeDescription), CRC::CRC_32(), hash);
|
||||||
|
|
||||||
VkPipelineInputAssemblyStateCreateInfo assemblyInfo = {
|
VkPipelineInputAssemblyStateCreateInfo assemblyInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
@@ -115,6 +117,8 @@ PGraphicsPipeline PipelineCache::createPipeline(Gfx::LegacyPipelineCreateInfo gf
|
|||||||
.topology = cast(gfxInfo.topology),
|
.topology = cast(gfxInfo.topology),
|
||||||
.primitiveRestartEnable = false,
|
.primitiveRestartEnable = false,
|
||||||
};
|
};
|
||||||
|
hash = CRC::Calculate(&assemblyInfo, sizeof(VkPipelineInputAssemblyStateCreateInfo), CRC::CRC_32(), hash);
|
||||||
|
|
||||||
VkPipelineViewportStateCreateInfo viewportInfo = {
|
VkPipelineViewportStateCreateInfo viewportInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
@@ -124,6 +128,7 @@ PGraphicsPipeline PipelineCache::createPipeline(Gfx::LegacyPipelineCreateInfo gf
|
|||||||
.scissorCount = 1,
|
.scissorCount = 1,
|
||||||
.pScissors = nullptr,
|
.pScissors = nullptr,
|
||||||
};
|
};
|
||||||
|
hash = CRC::Calculate(&viewportInfo, sizeof(VkPipelineViewportStateCreateInfo), CRC::CRC_32(), hash);
|
||||||
VkPipelineRasterizationStateCreateInfo rasterizationState = {
|
VkPipelineRasterizationStateCreateInfo rasterizationState = {
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
@@ -191,7 +196,10 @@ PGraphicsPipeline PipelineCache::createPipeline(Gfx::LegacyPipelineCreateInfo gf
|
|||||||
StaticArray<VkDynamicState, 2> dynamicEnabled;
|
StaticArray<VkDynamicState, 2> dynamicEnabled;
|
||||||
dynamicEnabled[numDynamicEnabled++] = VK_DYNAMIC_STATE_VIEWPORT;
|
dynamicEnabled[numDynamicEnabled++] = VK_DYNAMIC_STATE_VIEWPORT;
|
||||||
dynamicEnabled[numDynamicEnabled++] = VK_DYNAMIC_STATE_SCISSOR;
|
dynamicEnabled[numDynamicEnabled++] = VK_DYNAMIC_STATE_SCISSOR;
|
||||||
|
|
||||||
|
if (graphicsPipelines.contains(hash)) {
|
||||||
|
return graphicsPipelines[hash];
|
||||||
|
}
|
||||||
VkPipelineDynamicStateCreateInfo dynamicState = {
|
VkPipelineDynamicStateCreateInfo dynamicState = {
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
@@ -206,7 +214,7 @@ PGraphicsPipeline PipelineCache::createPipeline(Gfx::LegacyPipelineCreateInfo gf
|
|||||||
.pNext = 0,
|
.pNext = 0,
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.stageCount = stageCount,
|
.stageCount = stageCount,
|
||||||
.pStages = stageInfos,
|
.pStages = stageInfos.data(),
|
||||||
.pVertexInputState = &vertexInput,
|
.pVertexInputState = &vertexInput,
|
||||||
.pInputAssemblyState = &assemblyInfo,
|
.pInputAssemblyState = &assemblyInfo,
|
||||||
.pViewportState = &viewportInfo,
|
.pViewportState = &viewportInfo,
|
||||||
@@ -236,8 +244,7 @@ PGraphicsPipeline PipelineCache::createPipeline(Gfx::MeshPipelineCreateInfo gfxI
|
|||||||
uint32 hash = layout->getHash();
|
uint32 hash = layout->getHash();
|
||||||
uint32 stageCount = 0;
|
uint32 stageCount = 0;
|
||||||
|
|
||||||
VkPipelineShaderStageCreateInfo stageInfos[3];
|
StaticArray<VkPipelineShaderStageCreateInfo, 3> stageInfos;
|
||||||
std::memset(stageInfos, 0, sizeof(stageInfos));
|
|
||||||
|
|
||||||
if (gfxInfo.taskShader != nullptr) {
|
if (gfxInfo.taskShader != nullptr) {
|
||||||
PTaskShader taskShader = gfxInfo.taskShader.cast<TaskShader>();
|
PTaskShader taskShader = gfxInfo.taskShader.cast<TaskShader>();
|
||||||
@@ -276,7 +283,7 @@ PGraphicsPipeline PipelineCache::createPipeline(Gfx::MeshPipelineCreateInfo gfxI
|
|||||||
.pSpecializationInfo = nullptr,
|
.pSpecializationInfo = nullptr,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
hash = CRC::Calculate(stageInfos, sizeof(stageInfos), CRC::CRC_32(), hash);
|
hash = CRC::Calculate(stageInfos.data(), sizeof(stageInfos), CRC::CRC_32(), hash);
|
||||||
|
|
||||||
VkPipelineViewportStateCreateInfo viewportInfo = {
|
VkPipelineViewportStateCreateInfo viewportInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
|
||||||
@@ -401,7 +408,7 @@ PGraphicsPipeline PipelineCache::createPipeline(Gfx::MeshPipelineCreateInfo gfxI
|
|||||||
.pNext = 0,
|
.pNext = 0,
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.stageCount = stageCount,
|
.stageCount = stageCount,
|
||||||
.pStages = stageInfos,
|
.pStages = stageInfos.data(),
|
||||||
.pVertexInputState = nullptr,
|
.pVertexInputState = nullptr,
|
||||||
.pInputAssemblyState = nullptr,
|
.pInputAssemblyState = nullptr,
|
||||||
.pViewportState = &viewportInfo,
|
.pViewportState = &viewportInfo,
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ struct Globals {
|
|||||||
bool usePositionOnly = true;
|
bool usePositionOnly = true;
|
||||||
bool useDepthCulling = true;
|
bool useDepthCulling = true;
|
||||||
bool useLightCulling = true;
|
bool useLightCulling = true;
|
||||||
|
bool useImagebasedLighting = true;
|
||||||
bool useRayTracing = false;
|
bool useRayTracing = false;
|
||||||
bool running = true;
|
bool running = true;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user