Trying to fix other passes

This commit is contained in:
2023-11-11 13:56:12 +01:00
parent 91555fcec3
commit 4c05886d38
24 changed files with 5792 additions and 93 deletions
+2 -1
View File
@@ -123,7 +123,8 @@
"latch": "cpp", "latch": "cpp",
"ranges": "cpp", "ranges": "cpp",
"source_location": "cpp", "source_location": "cpp",
"syncstream": "cpp" "syncstream": "cpp",
"stdfloat": "cpp"
}, },
"cmake.skipConfigureIfCachePresent": false, "cmake.skipConfigureIfCachePresent": false,
"cmake.configureArgs": [ "cmake.configureArgs": [
+1 -1
+2 -2
View File
@@ -15,9 +15,9 @@ layout(set=5)
ParameterBlock<LightCullingData> pLightCullingData; ParameterBlock<LightCullingData> pLightCullingData;
[shader("pixel")] [shader("pixel")]
void pixelMain(in MaterialParameter params : PARAMETER, out float4 baseColor) float4 pixelMain(in MaterialParameter params : PARAMETER) : SV_Target
{ {
BRDF brdf = pMaterial.prepare(params); let brdf = pMaterial.prepare(params);
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 -11
View File
@@ -1,4 +1,5 @@
import Common; import Common;
import DispatchParams;
struct ComputeShaderInput struct ComputeShaderInput
{ {
@@ -8,17 +9,6 @@ struct ComputeShaderInput
uint groupIndex : SV_GroupIndex; uint groupIndex : SV_GroupIndex;
}; };
struct DispatchParams
{
uint3 numThreadGroups;
uint pad0;
uint3 numThreads;
uint pad1;
RWStructuredBuffer<Frustum> frustums;
}
ParameterBlock<DispatchParams> pDispatchParams;
[numthreads(BLOCK_SIZE, BLOCK_SIZE, 1)] [numthreads(BLOCK_SIZE, BLOCK_SIZE, 1)]
[shader("compute")] [shader("compute")]
void computeFrustums(ComputeShaderInput in) void computeFrustums(ComputeShaderInput in)
+3 -8
View File
@@ -1,4 +1,5 @@
import Common; import Common;
import DispatchParams;
import LightEnv; import LightEnv;
struct ComputeShaderInput struct ComputeShaderInput
@@ -10,11 +11,6 @@ struct ComputeShaderInput
}; };
struct CullingParams struct CullingParams
{ {
uint3 numThreadGroups;
uint pad0;
uint3 numThreads;
uint pad1;
Texture2D depthTextureVS; Texture2D depthTextureVS;
globallycoherent RWStructuredBuffer<uint> oLightIndexCounter; globallycoherent RWStructuredBuffer<uint> oLightIndexCounter;
@@ -25,9 +21,8 @@ struct CullingParams
RWTexture2D<uint2> oLightGrid; RWTexture2D<uint2> oLightGrid;
RWTexture2D<uint2> tLightGrid; RWTexture2D<uint2> tLightGrid;
StructuredBuffer<Frustum> frustums;
}; };
layout(set=2)
ParameterBlock<CullingParams> pCullingParams; ParameterBlock<CullingParams> pCullingParams;
// Debug // Debug
//Texture2D lightCountHeatMap; //Texture2D lightCountHeatMap;
@@ -81,7 +76,7 @@ void cullLights(ComputeShaderInput in)
uMaxDepth = 0x0; uMaxDepth = 0x0;
oLightCount = 0; oLightCount = 0;
tLightCount = 0; tLightCount = 0;
groupFrustum = pCullingParams.frustums[in.groupID.x + (in.groupID.y * pCullingParams.numThreadGroups.x)]; groupFrustum = pDispatchParams.frustums[in.groupID.x + (in.groupID.y * pDispatchParams.numThreadGroups.x)];
} }
GroupMemoryBarrierWithGroupSync(); GroupMemoryBarrierWithGroupSync();
+2
View File
@@ -15,6 +15,7 @@ struct SkyboxData
float4x4 transformMatrix; float4x4 transformMatrix;
float4 fogBlend; float4 fogBlend;
}; };
layout(set=1)
ParameterBlock<SkyboxData> pSkyboxData; ParameterBlock<SkyboxData> pSkyboxData;
[shader("vertex")] [shader("vertex")]
@@ -36,6 +37,7 @@ struct TextureData
TextureCube cubeMap2; TextureCube cubeMap2;
SamplerState sampler; SamplerState sampler;
}; };
layout(set=2)
ParameterBlock<TextureData> pTextures; ParameterBlock<TextureData> pTextures;
static const float lowerLimit = 0.0; static const float lowerLimit = 0.0;
static const float upperLimit = 0.1; static const float upperLimit = 0.1;
+12
View File
@@ -0,0 +1,12 @@
import Common;
struct DispatchParams
{
uint3 numThreadGroups;
uint pad0;
uint3 numThreads;
uint pad1;
RWStructuredBuffer<Frustum> frustums;
}
layout(set=1)
ParameterBlock<DispatchParams> pDispatchParams;
+5
View File
@@ -133,9 +133,13 @@ void TextureLoader::import(TextureImportArgs args, PTextureAsset textureAsset)
std::memcpy(memory.data(), dest, size); std::memcpy(memory.data(), dest, size);
free(dest); free(dest);
Array<uint8> rawPixels(totalWidth * totalHeight * 4);
std::memcpy(rawPixels.data(), data, rawPixels.size());
stbi_image_free(data); stbi_image_free(data);
ArchiveBuffer temp(graphics); ArchiveBuffer temp(graphics);
Serialization::save(temp, rawPixels);
Serialization::save(temp, memory); Serialization::save(temp, memory);
temp.rewind(); temp.rewind();
textureAsset->load(temp); textureAsset->load(temp);
@@ -149,6 +153,7 @@ void TextureLoader::import(TextureImportArgs args, PTextureAsset textureAsset)
Serialization::save(archive, TextureAsset::IDENTIFIER); Serialization::save(archive, TextureAsset::IDENTIFIER);
Serialization::save(archive, textureAsset->getName()); Serialization::save(archive, textureAsset->getName());
Serialization::save(archive, textureAsset->getFolderPath()); Serialization::save(archive, textureAsset->getFolderPath());
Serialization::save(archive, rawPixels);
Serialization::save(archive, memory); Serialization::save(archive, memory);
archive.writeToStream(stream); archive.writeToStream(stream);
+11
View File
@@ -73,6 +73,7 @@ void TextureAsset::save(ArchiveBuffer&) const
void TextureAsset::load(ArchiveBuffer& buffer) void TextureAsset::load(ArchiveBuffer& buffer)
{ {
Gfx::PGraphics graphics = buffer.getGraphics(); Gfx::PGraphics graphics = buffer.getGraphics();
Serialization::load(buffer, rawPixels);
Array<uint8> rawData; Array<uint8> rawData;
Serialization::load(buffer, rawData); Serialization::load(buffer, rawData);
ktxTexture2* kTexture; ktxTexture2* kTexture;
@@ -119,3 +120,13 @@ void TextureAsset::setTexture(Gfx::OTexture _texture)
{ {
texture = std::move(_texture); texture = std::move(_texture);
} }
uint32 TextureAsset::getWidth()
{
return texture->getSizeX();
}
uint32 TextureAsset::getHeight()
{
return texture->getSizeY();
}
+7
View File
@@ -18,7 +18,14 @@ public:
{ {
return texture; return texture;
} }
const Array<uint8>& getRawPixels()
{
return rawPixels;
}
uint32 getWidth();
uint32 getHeight();
private: private:
Array<uint8> rawPixels;
Gfx::OTexture texture; Gfx::OTexture texture;
friend class TextureLoader; friend class TextureLoader;
}; };
+1 -1
View File
@@ -35,7 +35,7 @@ concept has_dependencies = requires(Comp) { Comp::dependencies; };
x& get##x() { return *tl_##x; } \ x& get##x() { return *tl_##x; } \
const x& get##x() const { return *tl_##x; }; \ const x& get##x() const { return *tl_##x; }; \
public: \ public: \
constexpr static Dependencies<x> dependencies; constexpr static Dependencies<x> dependencies = {};
#define DECLARE_COMPONENT(x) \ #define DECLARE_COMPONENT(x) \
thread_local extern x* tl_##x; \ thread_local extern x* tl_##x; \
+3 -3
View File
@@ -29,12 +29,13 @@ BasePass::BasePass(Gfx::PGraphics graphics, PScene scene)
// tLightIndexList // tLightIndexList
lightCullingLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); lightCullingLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
// oLightGrid // oLightGrid
lightCullingLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER); lightCullingLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE);
// tLightGrid // tLightGrid
lightCullingLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER); lightCullingLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE);
lightCullingLayout->create(); lightCullingLayout->create();
basePassLayout->addDescriptorLayout(INDEX_LIGHT_CULLING, lightCullingLayout); basePassLayout->addDescriptorLayout(INDEX_LIGHT_CULLING, lightCullingLayout);
graphics->getShaderCompiler()->registerRenderPass("BasePass", "LegacyBasePass", true, true, "BasePass");
} }
BasePass::~BasePass() BasePass::~BasePass()
@@ -72,7 +73,6 @@ void BasePass::render()
descriptorSets[INDEX_LIGHT_CULLING]->updateTexture(3, tLightGrid); descriptorSets[INDEX_LIGHT_CULLING]->updateTexture(3, tLightGrid);
descriptorSets[INDEX_LIGHT_CULLING]->writeChanges(); descriptorSets[INDEX_LIGHT_CULLING]->writeChanges();
graphics->beginRenderPass(renderPass);
Gfx::ShaderPermutation permutation; Gfx::ShaderPermutation permutation;
if (graphics->supportMeshShading()) if (graphics->supportMeshShading())
{ {
@@ -32,15 +32,12 @@ void LightCullingPass::beginFrame(const Component::Camera& cam)
cullingDescriptorLayout->reset(); cullingDescriptorLayout->reset();
cullingDescriptorSet = cullingDescriptorLayout->allocateDescriptorSet(); cullingDescriptorSet = cullingDescriptorLayout->allocateDescriptorSet();
cullingDescriptorSet->updateBuffer(0, dispatchParamsBuffer); cullingDescriptorSet->updateBuffer(1, oLightIndexCounter);
cullingDescriptorSet->updateTexture(1, depthAttachment); cullingDescriptorSet->updateBuffer(2, tLightIndexCounter);
cullingDescriptorSet->updateBuffer(2, oLightIndexCounter); cullingDescriptorSet->updateBuffer(3, oLightIndexList);
cullingDescriptorSet->updateBuffer(3, tLightIndexCounter); cullingDescriptorSet->updateBuffer(4, tLightIndexList);
cullingDescriptorSet->updateBuffer(4, oLightIndexList); cullingDescriptorSet->updateTexture(5, Gfx::PTexture2D(oLightGrid));
cullingDescriptorSet->updateBuffer(5, tLightIndexList); cullingDescriptorSet->updateTexture(6, Gfx::PTexture2D(tLightGrid));
cullingDescriptorSet->updateTexture(6, Gfx::PTexture2D(oLightGrid));
cullingDescriptorSet->updateTexture(7, Gfx::PTexture2D(tLightGrid));
cullingDescriptorSet->updateBuffer(8, frustumBuffer);
//std::cout << "LightCulling beginFrame()" << std::endl; //std::cout << "LightCulling beginFrame()" << std::endl;
//co_return; //co_return;
} }
@@ -58,11 +55,11 @@ void LightCullingPass::render()
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT); Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
depthAttachment->changeLayout(Gfx::SE_IMAGE_LAYOUT_GENERAL); depthAttachment->changeLayout(Gfx::SE_IMAGE_LAYOUT_GENERAL);
depthAttachment->transferOwnership(Gfx::QueueType::COMPUTE); depthAttachment->transferOwnership(Gfx::QueueType::COMPUTE);
cullingDescriptorSet->updateTexture(2, depthAttachment); cullingDescriptorSet->updateTexture(0, depthAttachment);
cullingDescriptorSet->writeChanges(); cullingDescriptorSet->writeChanges();
Gfx::PComputeCommand computeCommand = graphics->createComputeCommand("CullingCommand"); Gfx::PComputeCommand computeCommand = graphics->createComputeCommand("CullingCommand");
computeCommand->bindPipeline(cullingPipeline); computeCommand->bindPipeline(cullingPipeline);
computeCommand->bindDescriptor({ viewParamsSet, lightEnv->getDescriptorSet(), cullingDescriptorSet }); computeCommand->bindDescriptor({ viewParamsSet, dispatchParamsSet, cullingDescriptorSet, lightEnv->getDescriptorSet() });
computeCommand->dispatch(dispatchParams.numThreadGroups.x, dispatchParams.numThreadGroups.y, dispatchParams.numThreadGroups.z); computeCommand->dispatch(dispatchParams.numThreadGroups.x, dispatchParams.numThreadGroups.y, dispatchParams.numThreadGroups.z);
Array<Gfx::PComputeCommand> commands = {computeCommand}; Array<Gfx::PComputeCommand> commands = {computeCommand};
graphics->executeCommands(commands); graphics->executeCommands(commands);
@@ -96,31 +93,28 @@ void LightCullingPass::publishOutputs()
cullingDescriptorLayout = graphics->createDescriptorLayout("CullingLayout"); cullingDescriptorLayout = graphics->createDescriptorLayout("CullingLayout");
// Dispatchparams
cullingDescriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
//DepthTexture //DepthTexture
cullingDescriptorLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE); cullingDescriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE);
//o_lightIndexCounter //o_lightIndexCounter
cullingDescriptorLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); cullingDescriptorLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
//t_lightIndexCounter //t_lightIndexCounter
cullingDescriptorLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); cullingDescriptorLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
//o_lightIndexList //o_lightIndexList
cullingDescriptorLayout->addDescriptorBinding(4, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); cullingDescriptorLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
//t_lightIndexList //t_lightIndexList
cullingDescriptorLayout->addDescriptorBinding(5, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); cullingDescriptorLayout->addDescriptorBinding(4, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
//o_lightGrid //o_lightGrid
cullingDescriptorLayout->addDescriptorBinding(6, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE); cullingDescriptorLayout->addDescriptorBinding(5, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE);
//t_lightGrid //t_lightGrid
cullingDescriptorLayout->addDescriptorBinding(7, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE); cullingDescriptorLayout->addDescriptorBinding(6, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE);
//Frustums
cullingDescriptorLayout->addDescriptorBinding(8, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, viewportWidth * viewportHeight);
lightEnv = scene->getLightEnvironment(); lightEnv = scene->getLightEnvironment();
Gfx::OPipelineLayout cullingLayout = graphics->createPipelineLayout(); Gfx::OPipelineLayout cullingLayout = graphics->createPipelineLayout();
cullingLayout->addDescriptorLayout(0, viewParamsLayout); cullingLayout->addDescriptorLayout(0, viewParamsLayout);
cullingLayout->addDescriptorLayout(1, lightEnv->getDescriptorLayout()); cullingLayout->addDescriptorLayout(1, dispatchParamsLayout);
cullingLayout->addDescriptorLayout(2, cullingDescriptorLayout); cullingLayout->addDescriptorLayout(2, cullingDescriptorLayout);
cullingLayout->addDescriptorLayout(3, lightEnv->getDescriptorLayout());
cullingLayout->create(); cullingLayout->create();
ShaderCreateInfo createInfo; ShaderCreateInfo createInfo;
@@ -200,12 +194,12 @@ void LightCullingPass::setupFrustums()
dispatchParams.numThreads = numThreads; dispatchParams.numThreads = numThreads;
dispatchParams.numThreadGroups = numThreadGroups; dispatchParams.numThreadGroups = numThreadGroups;
frustumDescriptorLayout = graphics->createDescriptorLayout("FrustumLayout"); dispatchParamsLayout = graphics->createDescriptorLayout("FrustumLayout");
frustumDescriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER); dispatchParamsLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
frustumDescriptorLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER); dispatchParamsLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
Gfx::OPipelineLayout frustumLayout = graphics->createPipelineLayout(); Gfx::OPipelineLayout frustumLayout = graphics->createPipelineLayout();
frustumLayout->addDescriptorLayout(0, viewParamsLayout); frustumLayout->addDescriptorLayout(0, viewParamsLayout);
frustumLayout->addDescriptorLayout(1, frustumDescriptorLayout); frustumLayout->addDescriptorLayout(1, dispatchParamsLayout);
frustumLayout->create(); frustumLayout->create();
ShaderCreateInfo createInfo; ShaderCreateInfo createInfo;
createInfo.name = "Frustum"; createInfo.name = "Frustum";
@@ -236,14 +230,14 @@ void LightCullingPass::setupFrustums()
.dynamic = false, .dynamic = false,
}); });
frustumDescriptorSet = frustumDescriptorLayout->allocateDescriptorSet(); dispatchParamsSet = dispatchParamsLayout->allocateDescriptorSet();
frustumDescriptorSet->updateBuffer(0, frustumDispatchParamsBuffer); dispatchParamsSet->updateBuffer(0, frustumDispatchParamsBuffer);
frustumDescriptorSet->updateBuffer(1, frustumBuffer); dispatchParamsSet->updateBuffer(1, frustumBuffer);
frustumDescriptorSet->writeChanges(); dispatchParamsSet->writeChanges();
Gfx::PComputeCommand command = graphics->createComputeCommand("FrustumCommand"); Gfx::PComputeCommand command = graphics->createComputeCommand("FrustumCommand");
command->bindPipeline(frustumPipeline); command->bindPipeline(frustumPipeline);
command->bindDescriptor({ viewParamsSet, frustumDescriptorSet }); command->bindDescriptor({ viewParamsSet, dispatchParamsSet });
command->dispatch(numThreadGroups.x, numThreadGroups.y, numThreadGroups.z); command->dispatch(numThreadGroups.x, numThreadGroups.y, numThreadGroups.z);
Array<Gfx::PComputeCommand> commands = {command}; Array<Gfx::PComputeCommand> commands = {command};
graphics->executeCommands(commands); graphics->executeCommands(commands);
@@ -45,8 +45,8 @@ private:
Gfx::OShaderBuffer frustumBuffer; Gfx::OShaderBuffer frustumBuffer;
Gfx::OUniformBuffer dispatchParamsBuffer; Gfx::OUniformBuffer dispatchParamsBuffer;
Gfx::OUniformBuffer viewParamsBuffer; Gfx::OUniformBuffer viewParamsBuffer;
Gfx::ODescriptorLayout frustumDescriptorLayout; Gfx::ODescriptorLayout dispatchParamsLayout;
Gfx::PDescriptorSet frustumDescriptorSet; Gfx::PDescriptorSet dispatchParamsSet;
Gfx::OComputeShader frustumShader; Gfx::OComputeShader frustumShader;
Gfx::PComputePipeline frustumPipeline; Gfx::PComputePipeline frustumPipeline;
@@ -30,7 +30,6 @@ void RenderPass::beginFrame(const Component::Camera& cam)
.projectionMatrix = viewport->getProjectionMatrix(), .projectionMatrix = viewport->getProjectionMatrix(),
.cameraPosition = Vector4(cam.getCameraPosition(), 1), .cameraPosition = Vector4(cam.getCameraPosition(), 1),
.screenDimensions = Vector2(static_cast<float>(viewport->getSizeX()), static_cast<float>(viewport->getSizeY())), .screenDimensions = Vector2(static_cast<float>(viewport->getSizeX()), static_cast<float>(viewport->getSizeY())),
.pad0 = Vector2(0),
}; };
DataSource uniformUpdate = { DataSource uniformUpdate = {
.size = sizeof(ViewParameter), .size = sizeof(ViewParameter),
@@ -33,7 +33,6 @@ protected:
Matrix4 projectionMatrix; Matrix4 projectionMatrix;
Vector4 cameraPosition; Vector4 cameraPosition;
Vector2 screenDimensions; Vector2 screenDimensions;
Vector2 pad0;
} viewParams; } viewParams;
PRenderGraphResources resources; PRenderGraphResources resources;
Gfx::ODescriptorLayout viewParamsLayout; Gfx::ODescriptorLayout viewParamsLayout;
@@ -114,7 +114,7 @@ void SkyboxRenderPass::render()
Gfx::PRenderCommand renderCommand = graphics->createRenderCommand("SkyboxRender"); Gfx::PRenderCommand renderCommand = graphics->createRenderCommand("SkyboxRender");
renderCommand->setViewport(viewport); renderCommand->setViewport(viewport);
renderCommand->bindPipeline(pipeline); renderCommand->bindPipeline(pipeline);
renderCommand->bindDescriptor({skyboxDataSet, textureSet}); renderCommand->bindDescriptor({viewParamsSet, skyboxDataSet, textureSet});
renderCommand->bindVertexBuffer({ cubeBuffer }); renderCommand->bindVertexBuffer({ cubeBuffer });
renderCommand->draw(36, 1, 0, 0); renderCommand->draw(36, 1, 0, 0);
graphics->executeCommands(Array{ renderCommand }); graphics->executeCommands(Array{ renderCommand });
@@ -141,9 +141,9 @@ void SkyboxRenderPass::publishOutputs()
skyboxDataLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER); skyboxDataLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
skyboxDataLayout->create(); skyboxDataLayout->create();
textureLayout = graphics->createDescriptorLayout(); textureLayout = graphics->createDescriptorLayout();
textureLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE);
textureLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE); textureLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE);
textureLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE); textureLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_SAMPLER);
textureLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_SAMPLER);
textureLayout->create(); textureLayout->create();
skyboxSampler = graphics->createSamplerState({}); skyboxSampler = graphics->createSamplerState({});
@@ -160,6 +160,7 @@ void SkyboxRenderPass::createRenderPass()
ShaderCreateInfo createInfo; ShaderCreateInfo createInfo;
createInfo.name = "SkyboxVertex"; createInfo.name = "SkyboxVertex";
createInfo.additionalModules.add("Skybox");
createInfo.mainModule = "Skybox"; createInfo.mainModule = "Skybox";
createInfo.entryPoint = "vertexMain"; createInfo.entryPoint = "vertexMain";
vertexShader = graphics->createVertexShader(createInfo); vertexShader = graphics->createVertexShader(createInfo);
@@ -179,8 +180,9 @@ void SkyboxRenderPass::createRenderPass()
}); });
Gfx::OPipelineLayout pipelineLayout = graphics->createPipelineLayout(); Gfx::OPipelineLayout pipelineLayout = graphics->createPipelineLayout();
pipelineLayout->addDescriptorLayout(0, skyboxDataLayout); pipelineLayout->addDescriptorLayout(0, viewParamsLayout);
pipelineLayout->addDescriptorLayout(0, textureLayout); pipelineLayout->addDescriptorLayout(1, skyboxDataLayout);
pipelineLayout->addDescriptorLayout(2, textureLayout);
pipelineLayout->create(); pipelineLayout->create();
Gfx::LegacyPipelineCreateInfo gfxInfo; Gfx::LegacyPipelineCreateInfo gfxInfo;
+2 -2
View File
@@ -57,8 +57,8 @@ Window::~Window()
} }
Viewport::Viewport(PWindow owner, const ViewportCreateInfo& viewportInfo) Viewport::Viewport(PWindow owner, const ViewportCreateInfo& viewportInfo)
: sizeX(viewportInfo.dimensions.size.x) : sizeX(std::min(owner->getSizeX(), viewportInfo.dimensions.size.x))
, sizeY(viewportInfo.dimensions.size.y) , sizeY(std::min(owner->getSizeY(), viewportInfo.dimensions.size.y))
, offsetX(viewportInfo.dimensions.offset.x) , offsetX(viewportInfo.dimensions.offset.x)
, offsetY(viewportInfo.dimensions.offset.y) , offsetY(viewportInfo.dimensions.offset.y)
, fieldOfView(viewportInfo.fieldOfView) , fieldOfView(viewportInfo.fieldOfView)
+1 -1
View File
@@ -314,7 +314,7 @@ void RenderCommand::draw(uint32 vertexCount, uint32 instanceCount, int32 firstVe
void RenderCommand::drawIndexed(uint32 indexCount, uint32 instanceCount, int32 firstIndex, uint32 vertexOffset, uint32 firstInstance) void RenderCommand::drawIndexed(uint32 indexCount, uint32 instanceCount, int32 firstIndex, uint32 vertexOffset, uint32 firstInstance)
{ {
assert(threadId == std::this_thread::get_id()); assert(threadId == std::this_thread::get_id());
vkCmdDrawIndexed(handle, indexCount, instanceCount, firstIndex, vertexOffset, firstIndex); vkCmdDrawIndexed(handle, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
} }
void RenderCommand::dispatch(uint32 groupX, uint32 groupY, uint32 groupZ) void RenderCommand::dispatch(uint32 groupX, uint32 groupY, uint32 groupZ)
{ {
+11 -11
View File
@@ -4,17 +4,17 @@
#include <iostream> #include <iostream>
#define VK_CHECK(f) \ #define VK_CHECK(f) \
{ \ { \
VkResult res = (f); \ VkResult res = (f); \
if (res != VK_SUCCESS) \ if (res != VK_SUCCESS) \
{ \ { \
if(res == VK_ERROR_DEVICE_LOST) \ if(res == VK_ERROR_DEVICE_LOST) \
{ \ { \
std::this_thread::sleep_for(std::chrono::seconds(3)); \ std::this_thread::sleep_for(std::chrono::seconds(3)); \
} \ } \
std::cout << "Fatal : VkResult is \"" << res << "\" in " << __FILE__ << " at line " << __LINE__ << std::endl; \ std::cout << "Fatal : VkResult is " << res << " in " << __FILE__ << " at line " << __LINE__ << std::endl; \
assert(res == VK_SUCCESS); \ assert(res == VK_SUCCESS); \
} \ } \
} }
namespace Seele namespace Seele
+6 -5
View File
@@ -62,6 +62,7 @@ Window::Window(PGraphics graphics, const WindowCreateInfo &createInfo)
GLFWwindow *handle = glfwCreateWindow(createInfo.width, createInfo.height, createInfo.title, createInfo.bFullscreen ? glfwGetPrimaryMonitor() : nullptr, nullptr); GLFWwindow *handle = glfwCreateWindow(createInfo.width, createInfo.height, createInfo.title, createInfo.bFullscreen ? glfwGetPrimaryMonitor() : nullptr, nullptr);
windowHandle = handle; windowHandle = handle;
glfwSetWindowUserPointer(handle, this); glfwSetWindowUserPointer(handle, this);
glfwGetWindowSize(handle, &windowState.width, &windowState.height);
glfwSetKeyCallback(handle, &glfwKeyCallback); glfwSetKeyCallback(handle, &glfwKeyCallback);
glfwSetCursorPosCallback(handle, &glfwMouseMoveCallback); glfwSetCursorPosCallback(handle, &glfwMouseMoveCallback);
@@ -93,7 +94,7 @@ Window::Window(PGraphics graphics, const WindowCreateInfo &createInfo)
std::cerr << "Device not suitable for presenting to surface " << surface << ", use a different one" << std::endl; std::cerr << "Device not suitable for presenting to surface " << surface << ", use a different one" << std::endl;
} }
recreateSwapchain(createInfo); recreateSwapchain(windowState);
} }
Window::~Window() Window::~Window()
@@ -364,10 +365,10 @@ void Window::choosePresentMode(const Array<VkPresentModeKHR> &modes)
Viewport::Viewport(PGraphics graphics, PWindow owner, const ViewportCreateInfo &viewportInfo) Viewport::Viewport(PGraphics graphics, PWindow owner, const ViewportCreateInfo &viewportInfo)
: Gfx::Viewport(owner, viewportInfo), graphics(graphics) : Gfx::Viewport(owner, viewportInfo), graphics(graphics)
{ {
handle.width = static_cast<float>(viewportInfo.dimensions.size.x); handle.width = static_cast<float>(sizeX);
handle.height = static_cast<float>(viewportInfo.dimensions.size.y); handle.height = static_cast<float>(sizeY);
handle.x = static_cast<float>(viewportInfo.dimensions.offset.x); handle.x = static_cast<float>(offsetX);
handle.y = static_cast<float>(viewportInfo.dimensions.offset.y) + handle.height; handle.y = static_cast<float>(offsetY) + handle.height;
handle.height = -handle.height; handle.height = -handle.height;
handle.minDepth = 0.f; handle.minDepth = 0.f;
handle.maxDepth = 1.f; handle.maxDepth = 1.f;
+1 -1
View File
@@ -116,7 +116,7 @@ void Material::compile()
handle->generateDeclaration(codeStream); handle->generateDeclaration(codeStream);
} }
codeStream << "\ttypedef " << brdf.profile << " BRDF;\n"; codeStream << "\ttypedef " << brdf.profile << " BRDF;\n";
codeStream << "\t" << brdf.profile << " prepare(MaterialFragmentParameter input) {\n"; codeStream << "\t" << brdf.profile << " prepare(MaterialParameter input) {\n";
codeStream << "\t\t" << brdf.profile << " result;\n"; codeStream << "\t\t" << brdf.profile << " result;\n";
Map<std::string, std::string> varState; Map<std::string, std::string> varState;
for(const auto& [_, expr] :codeExpressions) for(const auto& [_, expr] :codeExpressions)
-1
View File
@@ -57,7 +57,6 @@ void GameView::update()
void GameView::commitUpdate() void GameView::commitUpdate()
{ {
} }
void GameView::prepareRender() void GameView::prepareRender()
+5682
View File
File diff suppressed because it is too large Load Diff