Trying to fix other passes
This commit is contained in:
Vendored
+2
-1
@@ -123,7 +123,8 @@
|
||||
"latch": "cpp",
|
||||
"ranges": "cpp",
|
||||
"source_location": "cpp",
|
||||
"syncstream": "cpp"
|
||||
"syncstream": "cpp",
|
||||
"stdfloat": "cpp"
|
||||
},
|
||||
"cmake.skipConfigureIfCachePresent": false,
|
||||
"cmake.configureArgs": [
|
||||
|
||||
Vendored
+1
-1
Submodule external/slang updated: 4547125ce9...cc222702a8
@@ -15,9 +15,9 @@ layout(set=5)
|
||||
ParameterBlock<LightCullingData> pLightCullingData;
|
||||
|
||||
[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);
|
||||
for(int i = 0; i < pLightEnv.numDirectionalLights; ++i)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import Common;
|
||||
import DispatchParams;
|
||||
|
||||
struct ComputeShaderInput
|
||||
{
|
||||
@@ -8,17 +9,6 @@ struct ComputeShaderInput
|
||||
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)]
|
||||
[shader("compute")]
|
||||
void computeFrustums(ComputeShaderInput in)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import Common;
|
||||
import DispatchParams;
|
||||
import LightEnv;
|
||||
|
||||
struct ComputeShaderInput
|
||||
@@ -10,11 +11,6 @@ struct ComputeShaderInput
|
||||
};
|
||||
struct CullingParams
|
||||
{
|
||||
uint3 numThreadGroups;
|
||||
uint pad0;
|
||||
uint3 numThreads;
|
||||
uint pad1;
|
||||
|
||||
Texture2D depthTextureVS;
|
||||
|
||||
globallycoherent RWStructuredBuffer<uint> oLightIndexCounter;
|
||||
@@ -25,9 +21,8 @@ struct CullingParams
|
||||
|
||||
RWTexture2D<uint2> oLightGrid;
|
||||
RWTexture2D<uint2> tLightGrid;
|
||||
|
||||
StructuredBuffer<Frustum> frustums;
|
||||
};
|
||||
layout(set=2)
|
||||
ParameterBlock<CullingParams> pCullingParams;
|
||||
// Debug
|
||||
//Texture2D lightCountHeatMap;
|
||||
@@ -81,7 +76,7 @@ void cullLights(ComputeShaderInput in)
|
||||
uMaxDepth = 0x0;
|
||||
oLightCount = 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();
|
||||
|
||||
@@ -15,6 +15,7 @@ struct SkyboxData
|
||||
float4x4 transformMatrix;
|
||||
float4 fogBlend;
|
||||
};
|
||||
layout(set=1)
|
||||
ParameterBlock<SkyboxData> pSkyboxData;
|
||||
|
||||
[shader("vertex")]
|
||||
@@ -36,6 +37,7 @@ struct TextureData
|
||||
TextureCube cubeMap2;
|
||||
SamplerState sampler;
|
||||
};
|
||||
layout(set=2)
|
||||
ParameterBlock<TextureData> pTextures;
|
||||
static const float lowerLimit = 0.0;
|
||||
static const float upperLimit = 0.1;
|
||||
|
||||
@@ -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;
|
||||
@@ -133,9 +133,13 @@ void TextureLoader::import(TextureImportArgs args, PTextureAsset textureAsset)
|
||||
std::memcpy(memory.data(), dest, size);
|
||||
free(dest);
|
||||
|
||||
Array<uint8> rawPixels(totalWidth * totalHeight * 4);
|
||||
std::memcpy(rawPixels.data(), data, rawPixels.size());
|
||||
|
||||
stbi_image_free(data);
|
||||
|
||||
ArchiveBuffer temp(graphics);
|
||||
Serialization::save(temp, rawPixels);
|
||||
Serialization::save(temp, memory);
|
||||
temp.rewind();
|
||||
textureAsset->load(temp);
|
||||
@@ -149,6 +153,7 @@ void TextureLoader::import(TextureImportArgs args, PTextureAsset textureAsset)
|
||||
Serialization::save(archive, TextureAsset::IDENTIFIER);
|
||||
Serialization::save(archive, textureAsset->getName());
|
||||
Serialization::save(archive, textureAsset->getFolderPath());
|
||||
Serialization::save(archive, rawPixels);
|
||||
Serialization::save(archive, memory);
|
||||
archive.writeToStream(stream);
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ void TextureAsset::save(ArchiveBuffer&) const
|
||||
void TextureAsset::load(ArchiveBuffer& buffer)
|
||||
{
|
||||
Gfx::PGraphics graphics = buffer.getGraphics();
|
||||
Serialization::load(buffer, rawPixels);
|
||||
Array<uint8> rawData;
|
||||
Serialization::load(buffer, rawData);
|
||||
ktxTexture2* kTexture;
|
||||
@@ -119,3 +120,13 @@ void TextureAsset::setTexture(Gfx::OTexture _texture)
|
||||
{
|
||||
texture = std::move(_texture);
|
||||
}
|
||||
|
||||
uint32 TextureAsset::getWidth()
|
||||
{
|
||||
return texture->getSizeX();
|
||||
}
|
||||
|
||||
uint32 TextureAsset::getHeight()
|
||||
{
|
||||
return texture->getSizeY();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,14 @@ public:
|
||||
{
|
||||
return texture;
|
||||
}
|
||||
const Array<uint8>& getRawPixels()
|
||||
{
|
||||
return rawPixels;
|
||||
}
|
||||
uint32 getWidth();
|
||||
uint32 getHeight();
|
||||
private:
|
||||
Array<uint8> rawPixels;
|
||||
Gfx::OTexture texture;
|
||||
friend class TextureLoader;
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ concept has_dependencies = requires(Comp) { Comp::dependencies; };
|
||||
x& get##x() { return *tl_##x; } \
|
||||
const x& get##x() const { return *tl_##x; }; \
|
||||
public: \
|
||||
constexpr static Dependencies<x> dependencies;
|
||||
constexpr static Dependencies<x> dependencies = {};
|
||||
|
||||
#define DECLARE_COMPONENT(x) \
|
||||
thread_local extern x* tl_##x; \
|
||||
|
||||
@@ -29,12 +29,13 @@ BasePass::BasePass(Gfx::PGraphics graphics, PScene scene)
|
||||
// tLightIndexList
|
||||
lightCullingLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
// oLightGrid
|
||||
lightCullingLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER);
|
||||
lightCullingLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE);
|
||||
// tLightGrid
|
||||
lightCullingLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER);
|
||||
lightCullingLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE);
|
||||
lightCullingLayout->create();
|
||||
|
||||
basePassLayout->addDescriptorLayout(INDEX_LIGHT_CULLING, lightCullingLayout);
|
||||
graphics->getShaderCompiler()->registerRenderPass("BasePass", "LegacyBasePass", true, true, "BasePass");
|
||||
}
|
||||
|
||||
BasePass::~BasePass()
|
||||
@@ -72,7 +73,6 @@ void BasePass::render()
|
||||
descriptorSets[INDEX_LIGHT_CULLING]->updateTexture(3, tLightGrid);
|
||||
descriptorSets[INDEX_LIGHT_CULLING]->writeChanges();
|
||||
|
||||
graphics->beginRenderPass(renderPass);
|
||||
Gfx::ShaderPermutation permutation;
|
||||
if (graphics->supportMeshShading())
|
||||
{
|
||||
|
||||
@@ -32,15 +32,12 @@ void LightCullingPass::beginFrame(const Component::Camera& cam)
|
||||
cullingDescriptorLayout->reset();
|
||||
cullingDescriptorSet = cullingDescriptorLayout->allocateDescriptorSet();
|
||||
|
||||
cullingDescriptorSet->updateBuffer(0, dispatchParamsBuffer);
|
||||
cullingDescriptorSet->updateTexture(1, depthAttachment);
|
||||
cullingDescriptorSet->updateBuffer(2, oLightIndexCounter);
|
||||
cullingDescriptorSet->updateBuffer(3, tLightIndexCounter);
|
||||
cullingDescriptorSet->updateBuffer(4, oLightIndexList);
|
||||
cullingDescriptorSet->updateBuffer(5, tLightIndexList);
|
||||
cullingDescriptorSet->updateTexture(6, Gfx::PTexture2D(oLightGrid));
|
||||
cullingDescriptorSet->updateTexture(7, Gfx::PTexture2D(tLightGrid));
|
||||
cullingDescriptorSet->updateBuffer(8, frustumBuffer);
|
||||
cullingDescriptorSet->updateBuffer(1, oLightIndexCounter);
|
||||
cullingDescriptorSet->updateBuffer(2, tLightIndexCounter);
|
||||
cullingDescriptorSet->updateBuffer(3, oLightIndexList);
|
||||
cullingDescriptorSet->updateBuffer(4, tLightIndexList);
|
||||
cullingDescriptorSet->updateTexture(5, Gfx::PTexture2D(oLightGrid));
|
||||
cullingDescriptorSet->updateTexture(6, Gfx::PTexture2D(tLightGrid));
|
||||
//std::cout << "LightCulling beginFrame()" << std::endl;
|
||||
//co_return;
|
||||
}
|
||||
@@ -58,11 +55,11 @@ void LightCullingPass::render()
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
depthAttachment->changeLayout(Gfx::SE_IMAGE_LAYOUT_GENERAL);
|
||||
depthAttachment->transferOwnership(Gfx::QueueType::COMPUTE);
|
||||
cullingDescriptorSet->updateTexture(2, depthAttachment);
|
||||
cullingDescriptorSet->updateTexture(0, depthAttachment);
|
||||
cullingDescriptorSet->writeChanges();
|
||||
Gfx::PComputeCommand computeCommand = graphics->createComputeCommand("CullingCommand");
|
||||
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);
|
||||
Array<Gfx::PComputeCommand> commands = {computeCommand};
|
||||
graphics->executeCommands(commands);
|
||||
@@ -95,32 +92,29 @@ void LightCullingPass::publishOutputs()
|
||||
});
|
||||
|
||||
cullingDescriptorLayout = graphics->createDescriptorLayout("CullingLayout");
|
||||
|
||||
// Dispatchparams
|
||||
cullingDescriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
|
||||
//DepthTexture
|
||||
cullingDescriptorLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE);
|
||||
cullingDescriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE);
|
||||
//o_lightIndexCounter
|
||||
cullingDescriptorLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
cullingDescriptorLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
//t_lightIndexCounter
|
||||
cullingDescriptorLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
cullingDescriptorLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
//o_lightIndexList
|
||||
cullingDescriptorLayout->addDescriptorBinding(4, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
cullingDescriptorLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
//t_lightIndexList
|
||||
cullingDescriptorLayout->addDescriptorBinding(5, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
cullingDescriptorLayout->addDescriptorBinding(4, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
//o_lightGrid
|
||||
cullingDescriptorLayout->addDescriptorBinding(6, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE);
|
||||
cullingDescriptorLayout->addDescriptorBinding(5, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE);
|
||||
//t_lightGrid
|
||||
cullingDescriptorLayout->addDescriptorBinding(7, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE);
|
||||
//Frustums
|
||||
cullingDescriptorLayout->addDescriptorBinding(8, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, viewportWidth * viewportHeight);
|
||||
cullingDescriptorLayout->addDescriptorBinding(6, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE);
|
||||
|
||||
lightEnv = scene->getLightEnvironment();
|
||||
|
||||
Gfx::OPipelineLayout cullingLayout = graphics->createPipelineLayout();
|
||||
cullingLayout->addDescriptorLayout(0, viewParamsLayout);
|
||||
cullingLayout->addDescriptorLayout(1, lightEnv->getDescriptorLayout());
|
||||
cullingLayout->addDescriptorLayout(1, dispatchParamsLayout);
|
||||
cullingLayout->addDescriptorLayout(2, cullingDescriptorLayout);
|
||||
cullingLayout->addDescriptorLayout(3, lightEnv->getDescriptorLayout());
|
||||
cullingLayout->create();
|
||||
|
||||
ShaderCreateInfo createInfo;
|
||||
@@ -200,12 +194,12 @@ void LightCullingPass::setupFrustums()
|
||||
dispatchParams.numThreads = numThreads;
|
||||
dispatchParams.numThreadGroups = numThreadGroups;
|
||||
|
||||
frustumDescriptorLayout = graphics->createDescriptorLayout("FrustumLayout");
|
||||
frustumDescriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
frustumDescriptorLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
dispatchParamsLayout = graphics->createDescriptorLayout("FrustumLayout");
|
||||
dispatchParamsLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
dispatchParamsLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
Gfx::OPipelineLayout frustumLayout = graphics->createPipelineLayout();
|
||||
frustumLayout->addDescriptorLayout(0, viewParamsLayout);
|
||||
frustumLayout->addDescriptorLayout(1, frustumDescriptorLayout);
|
||||
frustumLayout->addDescriptorLayout(1, dispatchParamsLayout);
|
||||
frustumLayout->create();
|
||||
ShaderCreateInfo createInfo;
|
||||
createInfo.name = "Frustum";
|
||||
@@ -236,14 +230,14 @@ void LightCullingPass::setupFrustums()
|
||||
.dynamic = false,
|
||||
});
|
||||
|
||||
frustumDescriptorSet = frustumDescriptorLayout->allocateDescriptorSet();
|
||||
frustumDescriptorSet->updateBuffer(0, frustumDispatchParamsBuffer);
|
||||
frustumDescriptorSet->updateBuffer(1, frustumBuffer);
|
||||
frustumDescriptorSet->writeChanges();
|
||||
dispatchParamsSet = dispatchParamsLayout->allocateDescriptorSet();
|
||||
dispatchParamsSet->updateBuffer(0, frustumDispatchParamsBuffer);
|
||||
dispatchParamsSet->updateBuffer(1, frustumBuffer);
|
||||
dispatchParamsSet->writeChanges();
|
||||
|
||||
Gfx::PComputeCommand command = graphics->createComputeCommand("FrustumCommand");
|
||||
command->bindPipeline(frustumPipeline);
|
||||
command->bindDescriptor({ viewParamsSet, frustumDescriptorSet });
|
||||
command->bindDescriptor({ viewParamsSet, dispatchParamsSet });
|
||||
command->dispatch(numThreadGroups.x, numThreadGroups.y, numThreadGroups.z);
|
||||
Array<Gfx::PComputeCommand> commands = {command};
|
||||
graphics->executeCommands(commands);
|
||||
|
||||
@@ -45,8 +45,8 @@ private:
|
||||
Gfx::OShaderBuffer frustumBuffer;
|
||||
Gfx::OUniformBuffer dispatchParamsBuffer;
|
||||
Gfx::OUniformBuffer viewParamsBuffer;
|
||||
Gfx::ODescriptorLayout frustumDescriptorLayout;
|
||||
Gfx::PDescriptorSet frustumDescriptorSet;
|
||||
Gfx::ODescriptorLayout dispatchParamsLayout;
|
||||
Gfx::PDescriptorSet dispatchParamsSet;
|
||||
Gfx::OComputeShader frustumShader;
|
||||
Gfx::PComputePipeline frustumPipeline;
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ void RenderPass::beginFrame(const Component::Camera& cam)
|
||||
.projectionMatrix = viewport->getProjectionMatrix(),
|
||||
.cameraPosition = Vector4(cam.getCameraPosition(), 1),
|
||||
.screenDimensions = Vector2(static_cast<float>(viewport->getSizeX()), static_cast<float>(viewport->getSizeY())),
|
||||
.pad0 = Vector2(0),
|
||||
};
|
||||
DataSource uniformUpdate = {
|
||||
.size = sizeof(ViewParameter),
|
||||
|
||||
@@ -33,7 +33,6 @@ protected:
|
||||
Matrix4 projectionMatrix;
|
||||
Vector4 cameraPosition;
|
||||
Vector2 screenDimensions;
|
||||
Vector2 pad0;
|
||||
} viewParams;
|
||||
PRenderGraphResources resources;
|
||||
Gfx::ODescriptorLayout viewParamsLayout;
|
||||
|
||||
@@ -114,7 +114,7 @@ void SkyboxRenderPass::render()
|
||||
Gfx::PRenderCommand renderCommand = graphics->createRenderCommand("SkyboxRender");
|
||||
renderCommand->setViewport(viewport);
|
||||
renderCommand->bindPipeline(pipeline);
|
||||
renderCommand->bindDescriptor({skyboxDataSet, textureSet});
|
||||
renderCommand->bindDescriptor({viewParamsSet, skyboxDataSet, textureSet});
|
||||
renderCommand->bindVertexBuffer({ cubeBuffer });
|
||||
renderCommand->draw(36, 1, 0, 0);
|
||||
graphics->executeCommands(Array{ renderCommand });
|
||||
@@ -141,9 +141,9 @@ void SkyboxRenderPass::publishOutputs()
|
||||
skyboxDataLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
skyboxDataLayout->create();
|
||||
textureLayout = graphics->createDescriptorLayout();
|
||||
textureLayout->addDescriptorBinding(0, 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(3, Gfx::SE_DESCRIPTOR_TYPE_SAMPLER);
|
||||
textureLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_SAMPLER);
|
||||
textureLayout->create();
|
||||
|
||||
skyboxSampler = graphics->createSamplerState({});
|
||||
@@ -160,6 +160,7 @@ void SkyboxRenderPass::createRenderPass()
|
||||
|
||||
ShaderCreateInfo createInfo;
|
||||
createInfo.name = "SkyboxVertex";
|
||||
createInfo.additionalModules.add("Skybox");
|
||||
createInfo.mainModule = "Skybox";
|
||||
createInfo.entryPoint = "vertexMain";
|
||||
vertexShader = graphics->createVertexShader(createInfo);
|
||||
@@ -179,8 +180,9 @@ void SkyboxRenderPass::createRenderPass()
|
||||
});
|
||||
|
||||
Gfx::OPipelineLayout pipelineLayout = graphics->createPipelineLayout();
|
||||
pipelineLayout->addDescriptorLayout(0, skyboxDataLayout);
|
||||
pipelineLayout->addDescriptorLayout(0, textureLayout);
|
||||
pipelineLayout->addDescriptorLayout(0, viewParamsLayout);
|
||||
pipelineLayout->addDescriptorLayout(1, skyboxDataLayout);
|
||||
pipelineLayout->addDescriptorLayout(2, textureLayout);
|
||||
pipelineLayout->create();
|
||||
|
||||
Gfx::LegacyPipelineCreateInfo gfxInfo;
|
||||
|
||||
@@ -57,8 +57,8 @@ Window::~Window()
|
||||
}
|
||||
|
||||
Viewport::Viewport(PWindow owner, const ViewportCreateInfo& viewportInfo)
|
||||
: sizeX(viewportInfo.dimensions.size.x)
|
||||
, sizeY(viewportInfo.dimensions.size.y)
|
||||
: sizeX(std::min(owner->getSizeX(), viewportInfo.dimensions.size.x))
|
||||
, sizeY(std::min(owner->getSizeY(), viewportInfo.dimensions.size.y))
|
||||
, offsetX(viewportInfo.dimensions.offset.x)
|
||||
, offsetY(viewportInfo.dimensions.offset.y)
|
||||
, fieldOfView(viewportInfo.fieldOfView)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
@@ -530,4 +530,4 @@ void CommandBufferManager::submitCommands(PSemaphore signalSemaphore)
|
||||
allocatedBuffers.add(new CmdBuffer(graphics, commandPool, this));
|
||||
activeCmdBuffer = allocatedBuffers.back();
|
||||
activeCmdBuffer->begin();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
#include <iostream>
|
||||
|
||||
#define VK_CHECK(f) \
|
||||
{ \
|
||||
VkResult res = (f); \
|
||||
if (res != VK_SUCCESS) \
|
||||
{ \
|
||||
if(res == VK_ERROR_DEVICE_LOST) \
|
||||
{ \
|
||||
std::this_thread::sleep_for(std::chrono::seconds(3)); \
|
||||
} \
|
||||
std::cout << "Fatal : VkResult is \"" << res << "\" in " << __FILE__ << " at line " << __LINE__ << std::endl; \
|
||||
assert(res == VK_SUCCESS); \
|
||||
} \
|
||||
{ \
|
||||
VkResult res = (f); \
|
||||
if (res != VK_SUCCESS) \
|
||||
{ \
|
||||
if(res == VK_ERROR_DEVICE_LOST) \
|
||||
{ \
|
||||
std::this_thread::sleep_for(std::chrono::seconds(3)); \
|
||||
} \
|
||||
std::cout << "Fatal : VkResult is " << res << " in " << __FILE__ << " at line " << __LINE__ << std::endl; \
|
||||
assert(res == VK_SUCCESS); \
|
||||
} \
|
||||
}
|
||||
|
||||
namespace Seele
|
||||
@@ -62,4 +62,4 @@ Gfx::SeFilter cast(const VkFilter &filter);
|
||||
VkSamplerMipmapMode cast(const Gfx::SeSamplerMipmapMode &filter);
|
||||
Gfx::SeSamplerMipmapMode cast(const VkSamplerMipmapMode &filter);
|
||||
} // namespace Vulkan
|
||||
} // namespace Seele
|
||||
} // namespace Seele
|
||||
|
||||
@@ -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);
|
||||
windowHandle = handle;
|
||||
glfwSetWindowUserPointer(handle, this);
|
||||
glfwGetWindowSize(handle, &windowState.width, &windowState.height);
|
||||
|
||||
glfwSetKeyCallback(handle, &glfwKeyCallback);
|
||||
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;
|
||||
}
|
||||
|
||||
recreateSwapchain(createInfo);
|
||||
recreateSwapchain(windowState);
|
||||
}
|
||||
|
||||
Window::~Window()
|
||||
@@ -364,10 +365,10 @@ void Window::choosePresentMode(const Array<VkPresentModeKHR> &modes)
|
||||
Viewport::Viewport(PGraphics graphics, PWindow owner, const ViewportCreateInfo &viewportInfo)
|
||||
: Gfx::Viewport(owner, viewportInfo), graphics(graphics)
|
||||
{
|
||||
handle.width = static_cast<float>(viewportInfo.dimensions.size.x);
|
||||
handle.height = static_cast<float>(viewportInfo.dimensions.size.y);
|
||||
handle.x = static_cast<float>(viewportInfo.dimensions.offset.x);
|
||||
handle.y = static_cast<float>(viewportInfo.dimensions.offset.y) + handle.height;
|
||||
handle.width = static_cast<float>(sizeX);
|
||||
handle.height = static_cast<float>(sizeY);
|
||||
handle.x = static_cast<float>(offsetX);
|
||||
handle.y = static_cast<float>(offsetY) + handle.height;
|
||||
handle.height = -handle.height;
|
||||
handle.minDepth = 0.f;
|
||||
handle.maxDepth = 1.f;
|
||||
@@ -392,4 +393,4 @@ void Viewport::move(uint32 newOffsetX, uint32 newOffsetY)
|
||||
offsetY = newOffsetY;
|
||||
handle.x = static_cast<float>(offsetX);
|
||||
handle.y = static_cast<float>(offsetY + sizeY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ void Material::compile()
|
||||
handle->generateDeclaration(codeStream);
|
||||
}
|
||||
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";
|
||||
Map<std::string, std::string> varState;
|
||||
for(const auto& [_, expr] :codeExpressions)
|
||||
|
||||
@@ -57,7 +57,6 @@ void GameView::update()
|
||||
|
||||
void GameView::commitUpdate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GameView::prepareRender()
|
||||
|
||||
+5682
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user