Changing descriptor update signature
This commit is contained in:
@@ -26,7 +26,7 @@ elseif(APPLE)
|
|||||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
||||||
endif()
|
endif()
|
||||||
target_include_directories(slang INTERFACE
|
target_include_directories(slang INTERFACE
|
||||||
$<BUILD_INTERFACE:${EXTERNAL_ROOT}/slang>
|
$<BUILD_INTERFACE:${EXTERNAL_ROOT}/slang/include>
|
||||||
$<INSTALL_INTERFACE:include>
|
$<INSTALL_INTERFACE:include>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-1
Submodule external/slang updated: 1a0bbb53c1...a77d50b724
@@ -151,7 +151,7 @@ void meshMain(
|
|||||||
// float3 displacement2 = pWaterMaterial.displacementTextures.Sample(pWaterMaterial.sampler, float3(worldPos.xz * pWaterMaterial.tile2, 1)).xyz * pWaterMaterial.contributeDisplacement2;
|
// float3 displacement2 = pWaterMaterial.displacementTextures.Sample(pWaterMaterial.sampler, float3(worldPos.xz * pWaterMaterial.tile2, 1)).xyz * pWaterMaterial.contributeDisplacement2;
|
||||||
// float3 displacement3 = pWaterMaterial.displacementTextures.Sample(pWaterMaterial.sampler, float3(worldPos.xz * pWaterMaterial.tile3, 2)).xyz * pWaterMaterial.contributeDisplacement3;
|
// float3 displacement3 = pWaterMaterial.displacementTextures.Sample(pWaterMaterial.sampler, float3(worldPos.xz * pWaterMaterial.tile3, 2)).xyz * pWaterMaterial.contributeDisplacement3;
|
||||||
// float3 displacement4 = pWaterMaterial.displacementTextures.Sample(pWaterMaterial.sampler, float3(worldPos.xz * pWaterMaterial.tile4, 3)).xyz * pWaterMaterial.contributeDisplacement4;
|
// float3 displacement4 = pWaterMaterial.displacementTextures.Sample(pWaterMaterial.sampler, float3(worldPos.xz * pWaterMaterial.tile4, 3)).xyz * pWaterMaterial.contributeDisplacement4;
|
||||||
float displacement = pTerrainData.displacement.Sample(pTerrainData.sampler, worldPos.xz);
|
float displacement = pTerrainData.displacement.SampleLevel(pTerrainData.sampler, worldPos.xz, 0);
|
||||||
|
|
||||||
float4 clipPos = mul(vp, float4(worldPos, 1));
|
float4 clipPos = mul(vp, float4(worldPos, 1));
|
||||||
float ndcDepth = clipPos.z / clipPos.w;
|
float ndcDepth = clipPos.z / clipPos.w;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ struct DispatchParams
|
|||||||
|
|
||||||
struct DispatchParamWrapper
|
struct DispatchParamWrapper
|
||||||
{
|
{
|
||||||
ParameterBlock<DispatchParams> p;
|
DispatchParams p;
|
||||||
RWStructuredBuffer<Frustum> frustums;
|
RWStructuredBuffer<Frustum> frustums;
|
||||||
}
|
}
|
||||||
ParameterBlock<DispatchParamWrapper> pDispatchParams;
|
ParameterBlock<DispatchParamWrapper> pDispatchParams;
|
||||||
@@ -10,9 +10,9 @@ import Scene;
|
|||||||
//};
|
//};
|
||||||
struct MaterialResources
|
struct MaterialResources
|
||||||
{
|
{
|
||||||
StructuredBuffer<float> floatArray;
|
|
||||||
Texture2D textureArray[512];
|
Texture2D textureArray[512];
|
||||||
SamplerState samplerArray[512];
|
SamplerState samplerArray[512];
|
||||||
|
StructuredBuffer<float> floatArray;
|
||||||
};
|
};
|
||||||
layout(set=4)
|
layout(set=4)
|
||||||
ParameterBlock<MaterialResources> pResources;
|
ParameterBlock<MaterialResources> pResources;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import MaterialParameter;
|
|||||||
import LightEnv;
|
import LightEnv;
|
||||||
import Scene;
|
import Scene;
|
||||||
import RayTracingData;
|
import RayTracingData;
|
||||||
import VertexData;
|
import StaticMeshVertexData;
|
||||||
import Material;
|
import Material;
|
||||||
import MATERIAL_FILE_NAME;
|
import MATERIAL_FILE_NAME;
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ DECLARE_REF(UniformBuffer)
|
|||||||
DECLARE_REF(ShaderBuffer)
|
DECLARE_REF(ShaderBuffer)
|
||||||
DECLARE_REF(Texture)
|
DECLARE_REF(Texture)
|
||||||
DECLARE_REF(Texture2D)
|
DECLARE_REF(Texture2D)
|
||||||
|
DECLARE_REF(Texture3D)
|
||||||
|
DECLARE_REF(TextureCube)
|
||||||
DECLARE_REF(Sampler)
|
DECLARE_REF(Sampler)
|
||||||
DECLARE_REF(TopLevelAS)
|
DECLARE_REF(TopLevelAS)
|
||||||
class DescriptorSet {
|
class DescriptorSet {
|
||||||
@@ -61,14 +63,14 @@ class DescriptorSet {
|
|||||||
DescriptorSet(PDescriptorLayout layout);
|
DescriptorSet(PDescriptorLayout layout);
|
||||||
virtual ~DescriptorSet();
|
virtual ~DescriptorSet();
|
||||||
virtual void writeChanges() = 0;
|
virtual void writeChanges() = 0;
|
||||||
virtual void updateBuffer(uint32 binding, PUniformBuffer uniformBuffer) = 0;
|
virtual void updateBuffer(uint32 binding, uint32 index, Gfx::PUniformBuffer uniformBuffer) = 0;
|
||||||
virtual void updateBuffer(uint32 binding, PIndexBuffer indexBuffer) = 0;
|
virtual void updateBuffer(uint32 binding, uint32 index, Gfx::PShaderBuffer shaderBuffer) = 0;
|
||||||
virtual void updateBuffer(uint32 binding, PShaderBuffer shaderBuffer) = 0;
|
virtual void updateBuffer(uint32 binding, uint32 index, Gfx::PIndexBuffer indexBuffer) = 0;
|
||||||
virtual void updateSampler(uint32 binding, PSampler sampler) = 0;
|
virtual void updateSampler(uint32 binding, uint32 index, Gfx::PSampler samplerState) = 0;
|
||||||
virtual void updateTexture(uint32 binding, PTexture texture, PSampler samplerState = nullptr) = 0;
|
virtual void updateTexture(uint32 binding, uint32 index, Gfx::PTexture2D texture) = 0;
|
||||||
virtual void updateTextureArray(uint32_t binding, Array<PTexture2D> texture) = 0;
|
virtual void updateTexture(uint32 binding, uint32 index, Gfx::PTexture3D texture) = 0;
|
||||||
virtual void updateSamplerArray(uint32_t binding, Array<PSampler> samplers) = 0;
|
virtual void updateTexture(uint32 binding, uint32 index, Gfx::PTextureCube texture) = 0;
|
||||||
virtual void updateAccelerationStructure(uint32 binding, PTopLevelAS as) = 0;
|
virtual void updateAccelerationStructure(uint32 binding, uint32 index, Gfx::PTopLevelAS as) = 0;
|
||||||
bool operator<(PDescriptorSet other);
|
bool operator<(PDescriptorSet other);
|
||||||
|
|
||||||
constexpr PDescriptorLayout getLayout() const { return layout; }
|
constexpr PDescriptorLayout getLayout() const { return layout; }
|
||||||
|
|||||||
@@ -128,21 +128,21 @@ void BasePass::beginFrame(const Component::Camera& cam) {
|
|||||||
skyboxBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
skyboxBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
Gfx::SE_ACCESS_UNIFORM_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
Gfx::SE_ACCESS_UNIFORM_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||||
skyboxDataSet = skyboxDataLayout->allocateDescriptorSet();
|
skyboxDataSet = skyboxDataLayout->allocateDescriptorSet();
|
||||||
skyboxDataSet->updateBuffer(0, skyboxBuffer);
|
skyboxDataSet->updateBuffer(0, 0, skyboxBuffer);
|
||||||
skyboxDataSet->writeChanges();
|
skyboxDataSet->writeChanges();
|
||||||
textureSet = textureLayout->allocateDescriptorSet();
|
textureSet = textureLayout->allocateDescriptorSet();
|
||||||
textureSet->updateTexture(0, skybox.day);
|
textureSet->updateTexture(0, 0, skybox.day);
|
||||||
textureSet->updateTexture(1, skybox.night);
|
textureSet->updateTexture(1, 0, skybox.night);
|
||||||
textureSet->updateSampler(2, skyboxSampler);
|
textureSet->updateSampler(2, 0, skyboxSampler);
|
||||||
textureSet->writeChanges();
|
textureSet->writeChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasePass::render() {
|
void BasePass::render() {
|
||||||
opaqueCulling->updateBuffer(0, oLightIndexList);
|
opaqueCulling->updateBuffer(0, 0, oLightIndexList);
|
||||||
opaqueCulling->updateTexture(1, oLightGrid);
|
opaqueCulling->updateTexture(1, 0, oLightGrid);
|
||||||
transparentCulling->updateBuffer(0, tLightIndexList);
|
transparentCulling->updateBuffer(0, 0, tLightIndexList);
|
||||||
transparentCulling->updateTexture(1, tLightGrid);
|
transparentCulling->updateTexture(1, 0, tLightGrid);
|
||||||
opaqueCulling->writeChanges();
|
opaqueCulling->writeChanges();
|
||||||
transparentCulling->writeChanges();
|
transparentCulling->writeChanges();
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ void BasePass::render() {
|
|||||||
// Base Rendering
|
// Base Rendering
|
||||||
for (VertexData* vertexData : VertexData::getList()) {
|
for (VertexData* vertexData : VertexData::getList()) {
|
||||||
transparentData.addAll(vertexData->getTransparentData());
|
transparentData.addAll(vertexData->getTransparentData());
|
||||||
vertexData->getInstanceDataSet()->updateBuffer(6, cullingBuffer);
|
vertexData->getInstanceDataSet()->updateBuffer(6, 0, cullingBuffer);
|
||||||
vertexData->getInstanceDataSet()->writeChanges();
|
vertexData->getInstanceDataSet()->writeChanges();
|
||||||
permutation.setVertexData(vertexData->getTypeName());
|
permutation.setVertexData(vertexData->getTypeName());
|
||||||
const auto& materials = vertexData->getMaterialData();
|
const auto& materials = vertexData->getMaterialData();
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ void CachedDepthPass::render() {
|
|||||||
permutation.setDepthCulling(true);
|
permutation.setDepthCulling(true);
|
||||||
for (VertexData* vertexData : VertexData::getList()) {
|
for (VertexData* vertexData : VertexData::getList()) {
|
||||||
permutation.setVertexData(vertexData->getTypeName());
|
permutation.setVertexData(vertexData->getTypeName());
|
||||||
vertexData->getInstanceDataSet()->updateBuffer(6, cullingBuffer);
|
vertexData->getInstanceDataSet()->updateBuffer(6, 0, cullingBuffer);
|
||||||
vertexData->getInstanceDataSet()->writeChanges();
|
vertexData->getInstanceDataSet()->writeChanges();
|
||||||
|
|
||||||
// Create Pipeline(VertexData)
|
// Create Pipeline(VertexData)
|
||||||
@@ -63,7 +63,7 @@ void CachedDepthPass::render() {
|
|||||||
// SceneData => per meshtype
|
// SceneData => per meshtype
|
||||||
Gfx::PermutationId id(permutation);
|
Gfx::PermutationId id(permutation);
|
||||||
|
|
||||||
Gfx::ORenderCommand command = graphics->createRenderCommand("DepthRender");
|
Gfx::ORenderCommand command = graphics->createRenderCommand("CullingRender");
|
||||||
command->setViewport(viewport);
|
command->setViewport(viewport);
|
||||||
|
|
||||||
const Gfx::ShaderCollection* collection = graphics->getShaderCompiler()->findShaders(id);
|
const Gfx::ShaderCollection* collection = graphics->getShaderCompiler()->findShaders(id);
|
||||||
|
|||||||
@@ -75,8 +75,8 @@ void DepthCullingPass::render() {
|
|||||||
|
|
||||||
depthMipBuffer->rotateBuffer(depthMipBuffer->getNumElements() * sizeof(uint32));
|
depthMipBuffer->rotateBuffer(depthMipBuffer->getNumElements() * sizeof(uint32));
|
||||||
Gfx::PDescriptorSet set = depthAttachmentLayout->allocateDescriptorSet();
|
Gfx::PDescriptorSet set = depthAttachmentLayout->allocateDescriptorSet();
|
||||||
set->updateTexture(0, Gfx::PTexture2D(depthAttachment.getTexture()));
|
set->updateTexture(0, 0, depthAttachment.getTexture());
|
||||||
set->updateBuffer(1, depthMipBuffer);
|
set->updateBuffer(1, 0, depthMipBuffer);
|
||||||
set->writeChanges();
|
set->writeChanges();
|
||||||
|
|
||||||
timestamps->write(Gfx::SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT, "MipBegin");
|
timestamps->write(Gfx::SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT, "MipBegin");
|
||||||
@@ -125,7 +125,7 @@ void DepthCullingPass::render() {
|
|||||||
permutation.setDepthCulling(getGlobals().useDepthCulling);
|
permutation.setDepthCulling(getGlobals().useDepthCulling);
|
||||||
for (VertexData* vertexData : VertexData::getList()) {
|
for (VertexData* vertexData : VertexData::getList()) {
|
||||||
permutation.setVertexData(vertexData->getTypeName());
|
permutation.setVertexData(vertexData->getTypeName());
|
||||||
vertexData->getInstanceDataSet()->updateBuffer(6, cullingBuffer);
|
vertexData->getInstanceDataSet()->updateBuffer(6, 0, cullingBuffer);
|
||||||
vertexData->getInstanceDataSet()->writeChanges();
|
vertexData->getInstanceDataSet()->writeChanges();
|
||||||
// Create Pipeline(VertexData)
|
// Create Pipeline(VertexData)
|
||||||
// Descriptors:
|
// Descriptors:
|
||||||
|
|||||||
@@ -42,13 +42,13 @@ void LightCullingPass::render() {
|
|||||||
Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||||
tLightGrid->pipelineBarrier(Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, Gfx::SE_ACCESS_SHADER_WRITE_BIT,
|
tLightGrid->pipelineBarrier(Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, Gfx::SE_ACCESS_SHADER_WRITE_BIT,
|
||||||
Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||||
cullingDescriptorSet->updateTexture(0, depthAttachment);
|
cullingDescriptorSet->updateTexture(0, 0, depthAttachment);
|
||||||
cullingDescriptorSet->updateBuffer(1, oLightIndexCounter);
|
cullingDescriptorSet->updateBuffer(1, 0, oLightIndexCounter);
|
||||||
cullingDescriptorSet->updateBuffer(2, tLightIndexCounter);
|
cullingDescriptorSet->updateBuffer(2, 0, tLightIndexCounter);
|
||||||
cullingDescriptorSet->updateBuffer(3, oLightIndexList);
|
cullingDescriptorSet->updateBuffer(3, 0, oLightIndexList);
|
||||||
cullingDescriptorSet->updateBuffer(4, tLightIndexList);
|
cullingDescriptorSet->updateBuffer(4, 0, tLightIndexList);
|
||||||
cullingDescriptorSet->updateTexture(5, Gfx::PTexture2D(oLightGrid));
|
cullingDescriptorSet->updateTexture(5, 0, oLightGrid);
|
||||||
cullingDescriptorSet->updateTexture(6, Gfx::PTexture2D(tLightGrid));
|
cullingDescriptorSet->updateTexture(6, 0, tLightGrid);
|
||||||
cullingDescriptorSet->writeChanges();
|
cullingDescriptorSet->writeChanges();
|
||||||
Gfx::OComputeCommand computeCommand = graphics->createComputeCommand("CullingCommand");
|
Gfx::OComputeCommand computeCommand = graphics->createComputeCommand("CullingCommand");
|
||||||
if (getGlobals().useLightCulling) {
|
if (getGlobals().useLightCulling) {
|
||||||
@@ -96,8 +96,8 @@ void LightCullingPass::publishOutputs() {
|
|||||||
dispatchParamsBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
dispatchParamsBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
Gfx::SE_ACCESS_UNIFORM_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
Gfx::SE_ACCESS_UNIFORM_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||||
dispatchParamsSet = dispatchParamsLayout->allocateDescriptorSet();
|
dispatchParamsSet = dispatchParamsLayout->allocateDescriptorSet();
|
||||||
dispatchParamsSet->updateBuffer(0, dispatchParamsBuffer);
|
dispatchParamsSet->updateBuffer(0, 0, dispatchParamsBuffer);
|
||||||
dispatchParamsSet->updateBuffer(1, frustumBuffer);
|
dispatchParamsSet->updateBuffer(1, 0, frustumBuffer);
|
||||||
dispatchParamsSet->writeChanges();
|
dispatchParamsSet->writeChanges();
|
||||||
|
|
||||||
cullingDescriptorLayout = graphics->createDescriptorLayout("pCullingParams");
|
cullingDescriptorLayout = graphics->createDescriptorLayout("pCullingParams");
|
||||||
@@ -305,8 +305,8 @@ void LightCullingPass::setupFrustums() {
|
|||||||
Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||||
|
|
||||||
Gfx::PDescriptorSet dispatchParamsSet = dispatchParamsLayout->allocateDescriptorSet();
|
Gfx::PDescriptorSet dispatchParamsSet = dispatchParamsLayout->allocateDescriptorSet();
|
||||||
dispatchParamsSet->updateBuffer(0, frustumDispatchParamsBuffer);
|
dispatchParamsSet->updateBuffer(0, 0, frustumDispatchParamsBuffer);
|
||||||
dispatchParamsSet->updateBuffer(1, frustumBuffer);
|
dispatchParamsSet->updateBuffer(1, 0, frustumBuffer);
|
||||||
dispatchParamsSet->writeChanges();
|
dispatchParamsSet->writeChanges();
|
||||||
|
|
||||||
Gfx::OComputeCommand command = graphics->createComputeCommand("FrustumCommand");
|
Gfx::OComputeCommand command = graphics->createComputeCommand("FrustumCommand");
|
||||||
|
|||||||
@@ -103,9 +103,9 @@ void RayTracingPass::render() {
|
|||||||
.bottomLevelStructures = accelerationStructures,
|
.bottomLevelStructures = accelerationStructures,
|
||||||
});
|
});
|
||||||
Gfx::PDescriptorSet desc = paramsLayout->allocateDescriptorSet();
|
Gfx::PDescriptorSet desc = paramsLayout->allocateDescriptorSet();
|
||||||
desc->updateAccelerationStructure(0, tlas);
|
desc->updateAccelerationStructure(0, 0, tlas);
|
||||||
desc->updateTexture(1, Gfx::PTexture2D(texture));
|
desc->updateTexture(1, 0, texture);
|
||||||
desc->updateBuffer(2, StaticMeshVertexData::getInstance()->getIndexBuffer());
|
desc->updateBuffer(2, 0, StaticMeshVertexData::getInstance()->getIndexBuffer());
|
||||||
desc->writeChanges();
|
desc->writeChanges();
|
||||||
|
|
||||||
Gfx::ORenderCommand command = graphics->createRenderCommand("RayTracing");
|
Gfx::ORenderCommand command = graphics->createRenderCommand("RayTracing");
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ void RenderPass::beginFrame(const Component::Camera& cam) {
|
|||||||
Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT);
|
Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT);
|
||||||
viewParamsLayout->reset();
|
viewParamsLayout->reset();
|
||||||
viewParamsSet = viewParamsLayout->allocateDescriptorSet();
|
viewParamsSet = viewParamsLayout->allocateDescriptorSet();
|
||||||
viewParamsSet->updateBuffer(0, viewParamsBuffer);
|
viewParamsSet->updateBuffer(0, 0, viewParamsBuffer);
|
||||||
viewParamsSet->writeChanges();
|
viewParamsSet->writeChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,9 +86,9 @@ void TerrainRenderer::beginFrame() {
|
|||||||
Gfx::SE_PIPELINE_STAGE_TASK_SHADER_BIT_EXT);
|
Gfx::SE_PIPELINE_STAGE_TASK_SHADER_BIT_EXT);
|
||||||
|
|
||||||
set = layout->allocateDescriptorSet();
|
set = layout->allocateDescriptorSet();
|
||||||
set->updateBuffer(0, tilesBuffer);
|
set->updateBuffer(0, 0, tilesBuffer);
|
||||||
set->updateTexture(1, Gfx::PTexture2D(displacementMap));
|
set->updateTexture(1, 0, Gfx::PTexture2D(displacementMap));
|
||||||
set->updateSampler(2, sampler);
|
set->updateSampler(2, 0, sampler);
|
||||||
set->writeChanges();
|
set->writeChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ void TextPass::beginFrame(const Component::Camera& cam) {
|
|||||||
}
|
}
|
||||||
auto proj = viewport->getProjectionMatrix();
|
auto proj = viewport->getProjectionMatrix();
|
||||||
projectionBuffer->updateContents(0, sizeof(Matrix4), &proj);
|
projectionBuffer->updateContents(0, sizeof(Matrix4), &proj);
|
||||||
generalSet->updateBuffer(1, projectionBuffer);
|
generalSet->updateBuffer(1, 0, projectionBuffer);
|
||||||
generalSet->writeChanges();
|
generalSet->writeChanges();
|
||||||
// co_return;
|
// co_return;
|
||||||
}
|
}
|
||||||
@@ -139,8 +139,8 @@ void TextPass::createRenderPass() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
generalSet = generalLayout->allocateDescriptorSet();
|
generalSet = generalLayout->allocateDescriptorSet();
|
||||||
generalSet->updateBuffer(0, projectionBuffer);
|
generalSet->updateBuffer(0, 0, projectionBuffer);
|
||||||
generalSet->updateSampler(1, glyphSampler);
|
generalSet->updateSampler(1, 0, glyphSampler);
|
||||||
generalSet->writeChanges();
|
generalSet->writeChanges();
|
||||||
|
|
||||||
pipelineLayout = graphics->createPipelineLayout();
|
pipelineLayout = graphics->createPipelineLayout();
|
||||||
@@ -194,7 +194,9 @@ TextPass::FontData& TextPass::getFontData(PFontAsset font) {
|
|||||||
|
|
||||||
textureArrayLayout->reset();
|
textureArrayLayout->reset();
|
||||||
fd.textureArraySet = textureArrayLayout->allocateDescriptorSet();
|
fd.textureArraySet = textureArrayLayout->allocateDescriptorSet();
|
||||||
fd.textureArraySet->updateTextureArray(0, textures);
|
for (uint32 i = 0; i < textures.size(); ++i) {
|
||||||
|
fd.textureArraySet->updateTexture(0, i, textures[i]);
|
||||||
|
}
|
||||||
fd.textureArraySet->writeChanges();
|
fd.textureArraySet->writeChanges();
|
||||||
return fontData[font];
|
return fontData[font];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,21 @@ UIPass::~UIPass() {}
|
|||||||
void UIPass::beginFrame(const Component::Camera& cam) {
|
void UIPass::beginFrame(const Component::Camera& cam) {
|
||||||
RenderPass::beginFrame(cam);
|
RenderPass::beginFrame(cam);
|
||||||
VertexBufferCreateInfo info = {
|
VertexBufferCreateInfo info = {
|
||||||
.sourceData = {.size = (uint32)(sizeof(UI::RenderElementStyle) * renderElements.size()), .data = (uint8*)renderElements.data()},
|
.sourceData =
|
||||||
|
{
|
||||||
|
.size = (uint32)(sizeof(UI::RenderElementStyle) * renderElements.size()),
|
||||||
|
.data = (uint8*)renderElements.data(),
|
||||||
|
},
|
||||||
.vertexSize = sizeof(UI::RenderElementStyle),
|
.vertexSize = sizeof(UI::RenderElementStyle),
|
||||||
.numVertices = (uint32)renderElements.size(),
|
.numVertices = (uint32)renderElements.size(),
|
||||||
};
|
};
|
||||||
elementBuffer = graphics->createVertexBuffer(info);
|
elementBuffer = graphics->createVertexBuffer(info);
|
||||||
uint32 numTextures = static_cast<uint32>(usedTextures.size());
|
uint32 numTextures = static_cast<uint32>(usedTextures.size());
|
||||||
numTexturesBuffer->updateContents(0, sizeof(uint32), &numTextures);
|
numTexturesBuffer->updateContents(0, sizeof(uint32), &numTextures);
|
||||||
descriptorSet->updateBuffer(2, numTexturesBuffer);
|
descriptorSet->updateBuffer(2, 0, numTexturesBuffer);
|
||||||
descriptorSet->updateTextureArray(3, usedTextures);
|
for (uint32 i = 0; i < usedTextures.size(); ++i) {
|
||||||
|
descriptorSet->updateTexture(3, i, usedTextures[i]);
|
||||||
|
}
|
||||||
descriptorSet->writeChanges();
|
descriptorSet->writeChanges();
|
||||||
// co_return;
|
// co_return;
|
||||||
}
|
}
|
||||||
@@ -131,8 +137,8 @@ void UIPass::createRenderPass() {
|
|||||||
numTexturesBuffer = graphics->createUniformBuffer(info);
|
numTexturesBuffer = graphics->createUniformBuffer(info);
|
||||||
|
|
||||||
descriptorSet = descriptorLayout->allocateDescriptorSet();
|
descriptorSet = descriptorLayout->allocateDescriptorSet();
|
||||||
descriptorSet->updateBuffer(0, uniformBuffer);
|
descriptorSet->updateBuffer(0, 0, uniformBuffer);
|
||||||
descriptorSet->updateSampler(1, backgroundSampler);
|
descriptorSet->updateSampler(1, 0, backgroundSampler);
|
||||||
descriptorSet->writeChanges();
|
descriptorSet->writeChanges();
|
||||||
|
|
||||||
pipelineLayout = graphics->createPipelineLayout();
|
pipelineLayout = graphics->createPipelineLayout();
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ void VisibilityPass::render() {
|
|||||||
Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||||
visibilityDescriptor->reset();
|
visibilityDescriptor->reset();
|
||||||
visibilitySet = visibilityDescriptor->allocateDescriptorSet();
|
visibilitySet = visibilityDescriptor->allocateDescriptorSet();
|
||||||
visibilitySet->updateTexture(0, visibilityAttachment.getTexture());
|
visibilitySet->updateTexture(0, 0, visibilityAttachment.getTexture());
|
||||||
visibilitySet->updateBuffer(1, cullingBuffer);
|
visibilitySet->updateBuffer(1, 0, cullingBuffer);
|
||||||
visibilitySet->writeChanges();
|
visibilitySet->writeChanges();
|
||||||
|
|
||||||
query->beginQuery();
|
query->beginQuery();
|
||||||
|
|||||||
@@ -532,14 +532,14 @@ void WaterRenderer::updateFFTDescriptor() {
|
|||||||
Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||||
|
|
||||||
computeSet = computeLayout->allocateDescriptorSet();
|
computeSet = computeLayout->allocateDescriptorSet();
|
||||||
computeSet->updateBuffer(0, paramsBuffer);
|
computeSet->updateBuffer(0, 0, paramsBuffer);
|
||||||
computeSet->updateTexture(1, Gfx::PTexture2D(spectrumTextures));
|
computeSet->updateTexture(1, 0, spectrumTextures);
|
||||||
computeSet->updateTexture(2, Gfx::PTexture2D(initialSpectrumTextures));
|
computeSet->updateTexture(2, 0, initialSpectrumTextures);
|
||||||
computeSet->updateTexture(3, Gfx::PTexture2D(displacementTextures));
|
computeSet->updateTexture(3, 0, displacementTextures);
|
||||||
computeSet->updateTexture(4, Gfx::PTexture2D(slopeTextures));
|
computeSet->updateTexture(4, 0, slopeTextures);
|
||||||
computeSet->updateTexture(5, Gfx::PTexture2D(boyancyData));
|
computeSet->updateTexture(5, 0, boyancyData);
|
||||||
computeSet->updateBuffer(6, spectrumBuffer);
|
computeSet->updateBuffer(6, 0, spectrumBuffer);
|
||||||
computeSet->updateSampler(7, linearRepeatSampler);
|
computeSet->updateSampler(7, 0, linearRepeatSampler);
|
||||||
computeSet->writeChanges();
|
computeSet->writeChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -549,11 +549,11 @@ void WaterRenderer::updateMaterialDescriptor() {
|
|||||||
Gfx::SE_ACCESS_UNIFORM_READ_BIT,
|
Gfx::SE_ACCESS_UNIFORM_READ_BIT,
|
||||||
Gfx::SE_PIPELINE_STAGE_MESH_SHADER_BIT_EXT | Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
Gfx::SE_PIPELINE_STAGE_MESH_SHADER_BIT_EXT | Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||||
materialSet = materialLayout->allocateDescriptorSet();
|
materialSet = materialLayout->allocateDescriptorSet();
|
||||||
materialSet->updateBuffer(0, materialUniforms);
|
materialSet->updateBuffer(0, 0, materialUniforms);
|
||||||
materialSet->updateTexture(1, Gfx::PTexture2D(displacementTextures));
|
materialSet->updateTexture(1, 0, displacementTextures);
|
||||||
materialSet->updateTexture(2, Gfx::PTexture2D(slopeTextures));
|
materialSet->updateTexture(2, 0, slopeTextures);
|
||||||
materialSet->updateTexture(3, Gfx::PTextureCube(skyBox));
|
materialSet->updateTexture(3, 0, skyBox);
|
||||||
materialSet->updateSampler(4, linearRepeatSampler);
|
materialSet->updateSampler(4, 0, linearRepeatSampler);
|
||||||
materialSet->updateBuffer(5, waterTiles);
|
materialSet->updateBuffer(5, 0, waterTiles);
|
||||||
materialSet->writeChanges();
|
materialSet->writeChanges();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,13 +134,11 @@ void StaticMeshVertexData::init(Gfx::PGraphics _graphics) {
|
|||||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 2, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 2, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 3, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 3, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 4, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 4, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||||
for(uint32 i = 0; i < MAX_TEXCOORDS; ++i)
|
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||||
{
|
.binding = 5,
|
||||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||||
.binding = 5 + i,
|
.descriptorCount = MAX_TEXCOORDS,
|
||||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
descriptorLayout->create();
|
descriptorLayout->create();
|
||||||
descriptorSet = descriptorLayout->allocateDescriptorSet();
|
descriptorSet = descriptorLayout->allocateDescriptorSet();
|
||||||
}
|
}
|
||||||
@@ -220,13 +218,13 @@ void StaticMeshVertexData::updateBuffers() {
|
|||||||
colData.clear();
|
colData.clear();
|
||||||
descriptorLayout->reset();
|
descriptorLayout->reset();
|
||||||
descriptorSet = descriptorLayout->allocateDescriptorSet();
|
descriptorSet = descriptorLayout->allocateDescriptorSet();
|
||||||
descriptorSet->updateBuffer(0, positions);
|
descriptorSet->updateBuffer(0, 0, positions);
|
||||||
descriptorSet->updateBuffer(1, normals);
|
descriptorSet->updateBuffer(1, 0, normals);
|
||||||
descriptorSet->updateBuffer(2, tangents);
|
descriptorSet->updateBuffer(2, 0, tangents);
|
||||||
descriptorSet->updateBuffer(3, biTangents);
|
descriptorSet->updateBuffer(3, 0, biTangents);
|
||||||
descriptorSet->updateBuffer(4, colors);
|
descriptorSet->updateBuffer(4, 0, colors);
|
||||||
for (size_t i = 0; i < MAX_TEXCOORDS; ++i) {
|
for (size_t i = 0; i < MAX_TEXCOORDS; ++i) {
|
||||||
descriptorSet->updateBuffer(5 + i, texCoords[i]);
|
descriptorSet->updateBuffer(5, i, texCoords[i]);
|
||||||
}
|
}
|
||||||
descriptorSet->writeChanges();
|
descriptorSet->writeChanges();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,12 +165,12 @@ void VertexData::createDescriptors() {
|
|||||||
|
|
||||||
instanceDataLayout->reset();
|
instanceDataLayout->reset();
|
||||||
descriptorSet = instanceDataLayout->allocateDescriptorSet();
|
descriptorSet = instanceDataLayout->allocateDescriptorSet();
|
||||||
descriptorSet->updateBuffer(0, instanceBuffer);
|
descriptorSet->updateBuffer(0, 0, instanceBuffer);
|
||||||
descriptorSet->updateBuffer(1, instanceMeshDataBuffer);
|
descriptorSet->updateBuffer(1, 0, instanceMeshDataBuffer);
|
||||||
descriptorSet->updateBuffer(2, meshletBuffer);
|
descriptorSet->updateBuffer(2, 0, meshletBuffer);
|
||||||
descriptorSet->updateBuffer(3, primitiveIndicesBuffer);
|
descriptorSet->updateBuffer(3, 0, primitiveIndicesBuffer);
|
||||||
descriptorSet->updateBuffer(4, vertexIndicesBuffer);
|
descriptorSet->updateBuffer(4, 0, vertexIndicesBuffer);
|
||||||
descriptorSet->updateBuffer(5, cullingOffsetBuffer);
|
descriptorSet->updateBuffer(5, 0, cullingOffsetBuffer);
|
||||||
Material::updateDescriptor();
|
Material::updateDescriptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -248,18 +248,23 @@ void RenderCommand::bindPipeline(Gfx::PRayTracingPipeline gfxPipeline) {
|
|||||||
boundResources.add(PBufferAllocation(rtPipeline->miss));
|
boundResources.add(PBufferAllocation(rtPipeline->miss));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderCommand::bindDescriptor(Gfx::PDescriptorSet descriptorSet) {
|
void RenderCommand::bindDescriptor(Gfx::PDescriptorSet descriptor) {
|
||||||
assert(threadId == std::this_thread::get_id());
|
assert(threadId == std::this_thread::get_id());
|
||||||
auto descriptor = descriptorSet.cast<DescriptorSet>();
|
auto descriptorSet = descriptor.cast<DescriptorSet>();
|
||||||
assert(descriptor->writeDescriptors.size() == 0);
|
assert(descriptorSet->writeDescriptors.size() == 0);
|
||||||
descriptor->bind();
|
descriptorSet->bind();
|
||||||
boundResources.add(descriptor);
|
boundResources.add(descriptorSet);
|
||||||
for (auto binding : descriptor->boundResources) {
|
for (auto& binding : descriptorSet->boundResources) {
|
||||||
binding->bind();
|
for (auto& res : binding) {
|
||||||
boundResources.add(binding);
|
// partially bound descriptors can include nulls
|
||||||
|
if (res != nullptr) {
|
||||||
|
res->bind();
|
||||||
|
boundResources.add(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VkDescriptorSet setHandle = descriptor->getHandle();
|
VkDescriptorSet setHandle = descriptorSet->getHandle();
|
||||||
Gfx::PPipelineLayout layout = pipeline != nullptr ? pipeline->getPipelineLayout() : rtPipeline->getPipelineLayout();
|
Gfx::PPipelineLayout layout = pipeline != nullptr ? pipeline->getPipelineLayout() : rtPipeline->getPipelineLayout();
|
||||||
vkCmdBindDescriptorSets(handle, pipeline != nullptr ? VK_PIPELINE_BIND_POINT_GRAPHICS : VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR,
|
vkCmdBindDescriptorSets(handle, pipeline != nullptr ? VK_PIPELINE_BIND_POINT_GRAPHICS : VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR,
|
||||||
pipeline->getLayout(), layout->findParameter(descriptorSet->getName()), 1, &setHandle, 0,
|
pipeline->getLayout(), layout->findParameter(descriptorSet->getName()), 1, &setHandle, 0,
|
||||||
@@ -277,11 +282,13 @@ void RenderCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptorS
|
|||||||
descriptorSet->bind();
|
descriptorSet->bind();
|
||||||
boundResources.add(descriptorSet);
|
boundResources.add(descriptorSet);
|
||||||
|
|
||||||
for (auto binding : descriptorSet->boundResources) {
|
for (auto& binding : descriptorSet->boundResources) {
|
||||||
|
for (auto& res : binding) {
|
||||||
// partially bound descriptors can include nulls
|
// partially bound descriptors can include nulls
|
||||||
if (binding != nullptr) {
|
if (res != nullptr) {
|
||||||
binding->bind();
|
res->bind();
|
||||||
boundResources.add(binding);
|
boundResources.add(res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sets[layout->findParameter(descriptorSet->getName())] = descriptorSet->getHandle();
|
sets[layout->findParameter(descriptorSet->getName())] = descriptorSet->getHandle();
|
||||||
@@ -407,20 +414,24 @@ void ComputeCommand::bindPipeline(Gfx::PComputePipeline computePipeline) {
|
|||||||
pipeline->bind(handle);
|
pipeline->bind(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComputeCommand::bindDescriptor(Gfx::PDescriptorSet descriptorSet) {
|
void ComputeCommand::bindDescriptor(Gfx::PDescriptorSet descriptor) {
|
||||||
assert(threadId == std::this_thread::get_id());
|
assert(threadId == std::this_thread::get_id());
|
||||||
auto descriptor = descriptorSet.cast<DescriptorSet>();
|
auto descriptorSet = descriptor.cast<DescriptorSet>();
|
||||||
assert(descriptor->writeDescriptors.size() == 0);
|
assert(descriptorSet->writeDescriptors.size() == 0);
|
||||||
descriptor->bind();
|
descriptorSet->bind();
|
||||||
boundResources.add(descriptor.getHandle());
|
boundResources.add(descriptorSet.getHandle());
|
||||||
|
|
||||||
for (auto& binding : descriptor->boundResources) {
|
for (auto& binding : descriptorSet->boundResources) {
|
||||||
binding->bind();
|
for (auto& res : binding) {
|
||||||
boundResources.add(binding);
|
// partially bound descriptors can include nulls
|
||||||
|
if (res != nullptr) {
|
||||||
|
res->bind();
|
||||||
|
boundResources.add(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VkDescriptorSet setHandle = descriptor->getHandle();
|
VkDescriptorSet setHandle = descriptorSet->getHandle();
|
||||||
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->getLayout(),
|
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->getLayout(),
|
||||||
pipeline->getPipelineLayout()->findParameter(descriptorSet->getName()), 1, &setHandle,0,
|
pipeline->getPipelineLayout()->findParameter(descriptorSet->getName()), 1, &setHandle,0,
|
||||||
nullptr);
|
nullptr);
|
||||||
@@ -434,12 +445,14 @@ void ComputeCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptor
|
|||||||
assert(descriptorSet->writeDescriptors.size() == 0);
|
assert(descriptorSet->writeDescriptors.size() == 0);
|
||||||
descriptorSet->bind();
|
descriptorSet->bind();
|
||||||
boundResources.add(descriptorSet.getHandle());
|
boundResources.add(descriptorSet.getHandle());
|
||||||
|
for (auto& binding : descriptorSet->boundResources) {
|
||||||
// std::cout << "Binding descriptor " << descriptorSet->getHandle() << " to cmd " << handle << std::endl;
|
for (auto& res : binding) {
|
||||||
|
// partially bound descriptors can include nulls
|
||||||
for (auto binding : descriptorSet->boundResources) {
|
if (res != nullptr) {
|
||||||
binding->bind();
|
res->bind();
|
||||||
boundResources.add(binding);
|
boundResources.add(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sets[pipeline->getPipelineLayout()->findParameter(descriptorSet->getName())] = descriptorSet->getHandle();
|
sets[pipeline->getPipelineLayout()->findParameter(descriptorSet->getName())] = descriptorSet->getHandle();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,15 +163,15 @@ DescriptorSet::DescriptorSet(PGraphics graphics, PDescriptorPool owner)
|
|||||||
graphics(graphics), owner(owner) {
|
graphics(graphics), owner(owner) {
|
||||||
boundResources.resize(owner->getLayout()->getBindings().size());
|
boundResources.resize(owner->getLayout()->getBindings().size());
|
||||||
for (uint32 i = 0; i < boundResources.size(); ++i) {
|
for (uint32 i = 0; i < boundResources.size(); ++i) {
|
||||||
if(owner->getLayout()->getBindings()[i].descriptorCount > 1) std::abort();
|
boundResources[i].resize(owner->getLayout()->getBindings()[i].descriptorCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DescriptorSet::~DescriptorSet() {}
|
DescriptorSet::~DescriptorSet() {}
|
||||||
|
|
||||||
void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBuffer) {
|
void DescriptorSet::updateBuffer(uint32_t binding, uint32 index, Gfx::PUniformBuffer uniformBuffer) {
|
||||||
PUniformBuffer vulkanBuffer = uniformBuffer.cast<UniformBuffer>();
|
PUniformBuffer vulkanBuffer = uniformBuffer.cast<UniformBuffer>();
|
||||||
if (boundResources[binding] == vulkanBuffer->getAlloc()) {
|
if (boundResources[binding][index] == vulkanBuffer->getAlloc()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,18 +186,18 @@ void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBu
|
|||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
.dstSet = setHandle,
|
.dstSet = setHandle,
|
||||||
.dstBinding = binding,
|
.dstBinding = binding,
|
||||||
.dstArrayElement = 0,
|
.dstArrayElement = index,
|
||||||
.descriptorCount = 1,
|
.descriptorCount = 1,
|
||||||
.descriptorType = cast(layout->getBindings()[binding].descriptorType),
|
.descriptorType = cast(layout->getBindings()[binding].descriptorType),
|
||||||
.pBufferInfo = &bufferInfos.back(),
|
.pBufferInfo = &bufferInfos.back(),
|
||||||
});
|
});
|
||||||
|
|
||||||
boundResources[binding] = vulkanBuffer->getAlloc();
|
boundResources[binding][index] = vulkanBuffer->getAlloc();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PShaderBuffer shaderBuffer) {
|
void DescriptorSet::updateBuffer(uint32_t binding, uint32 index, Gfx::PShaderBuffer shaderBuffer) {
|
||||||
PShaderBuffer vulkanBuffer = shaderBuffer.cast<ShaderBuffer>();
|
PShaderBuffer vulkanBuffer = shaderBuffer.cast<ShaderBuffer>();
|
||||||
if (boundResources[binding] == vulkanBuffer->getAlloc()) {
|
if (boundResources[binding][index] == vulkanBuffer->getAlloc()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,18 +211,18 @@ void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PShaderBuffer shaderBuff
|
|||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
.dstSet = setHandle,
|
.dstSet = setHandle,
|
||||||
.dstBinding = binding,
|
.dstBinding = binding,
|
||||||
.dstArrayElement = 0,
|
.dstArrayElement = index,
|
||||||
.descriptorCount = 1,
|
.descriptorCount = 1,
|
||||||
.descriptorType = cast(layout->getBindings()[binding].descriptorType),
|
.descriptorType = cast(layout->getBindings()[binding].descriptorType),
|
||||||
.pBufferInfo = &bufferInfos.back(),
|
.pBufferInfo = &bufferInfos.back(),
|
||||||
});
|
});
|
||||||
|
|
||||||
boundResources[binding] = vulkanBuffer->getAlloc();
|
boundResources[binding][index] = vulkanBuffer->getAlloc();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PIndexBuffer indexBuffer) {
|
void DescriptorSet::updateBuffer(uint32_t binding, uint32 index, Gfx::PIndexBuffer indexBuffer) {
|
||||||
PIndexBuffer vulkanBuffer = indexBuffer.cast<IndexBuffer>();
|
PIndexBuffer vulkanBuffer = indexBuffer.cast<IndexBuffer>();
|
||||||
if (boundResources[binding] == vulkanBuffer->getAlloc()) {
|
if (boundResources[binding][index] == vulkanBuffer->getAlloc()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,18 +236,18 @@ void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PIndexBuffer indexBuffer
|
|||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
.dstSet = setHandle,
|
.dstSet = setHandle,
|
||||||
.dstBinding = binding,
|
.dstBinding = binding,
|
||||||
.dstArrayElement = 0,
|
.dstArrayElement = index,
|
||||||
.descriptorCount = 1,
|
.descriptorCount = 1,
|
||||||
.descriptorType = cast(layout->getBindings()[binding].descriptorType),
|
.descriptorType = cast(layout->getBindings()[binding].descriptorType),
|
||||||
.pBufferInfo = &bufferInfos.back(),
|
.pBufferInfo = &bufferInfos.back(),
|
||||||
});
|
});
|
||||||
|
|
||||||
boundResources[binding] = vulkanBuffer->getAlloc();
|
boundResources[binding][index] = vulkanBuffer->getAlloc();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorSet::updateSampler(uint32_t binding, Gfx::PSampler samplerState) {
|
void DescriptorSet::updateSampler(uint32_t binding, uint32 index, Gfx::PSampler samplerState) {
|
||||||
PSampler vulkanSampler = samplerState.cast<Sampler>();
|
PSampler vulkanSampler = samplerState.cast<Sampler>();
|
||||||
if (boundResources[binding] == vulkanSampler->getHandle()) {
|
if (boundResources[binding][index] == vulkanSampler->getHandle()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,24 +262,24 @@ void DescriptorSet::updateSampler(uint32_t binding, Gfx::PSampler samplerState)
|
|||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
.dstSet = setHandle,
|
.dstSet = setHandle,
|
||||||
.dstBinding = binding,
|
.dstBinding = binding,
|
||||||
.dstArrayElement = 0,
|
.dstArrayElement = index,
|
||||||
.descriptorCount = 1,
|
.descriptorCount = 1,
|
||||||
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER,
|
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER,
|
||||||
.pImageInfo = &imageInfos.back(),
|
.pImageInfo = &imageInfos.back(),
|
||||||
});
|
});
|
||||||
|
|
||||||
boundResources[binding] = vulkanSampler->getHandle();
|
boundResources[binding][index] = vulkanSampler->getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorSet::updateTexture(uint32_t binding, Gfx::PTexture texture, Gfx::PSampler samplerState) {
|
void DescriptorSet::updateTexture(uint32_t binding, uint32 index, Gfx::PTexture2D texture) {
|
||||||
TextureBase* vulkanTexture = texture.cast<TextureBase>().getHandle();
|
TextureBase* vulkanTexture = texture.cast<TextureBase>().getHandle();
|
||||||
if (boundResources[binding] == vulkanTexture->getHandle()) {
|
if (boundResources[binding][index] == vulkanTexture->getHandle()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// It is assumed that the image is in the correct layout
|
// It is assumed that the image is in the correct layout
|
||||||
imageInfos.add(VkDescriptorImageInfo{
|
imageInfos.add(VkDescriptorImageInfo{
|
||||||
.sampler = samplerState != nullptr ? samplerState.cast<Sampler>()->getSampler() : VK_NULL_HANDLE,
|
.sampler = VK_NULL_HANDLE,
|
||||||
.imageView = vulkanTexture->getView(),
|
.imageView = vulkanTexture->getView(),
|
||||||
.imageLayout = cast(vulkanTexture->getLayout()),
|
.imageLayout = cast(vulkanTexture->getLayout()),
|
||||||
});
|
});
|
||||||
@@ -288,73 +288,68 @@ void DescriptorSet::updateTexture(uint32_t binding, Gfx::PTexture texture, Gfx::
|
|||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
.dstSet = setHandle,
|
.dstSet = setHandle,
|
||||||
.dstBinding = binding,
|
.dstBinding = binding,
|
||||||
.dstArrayElement = 0,
|
.dstArrayElement = index,
|
||||||
.descriptorCount = 1,
|
.descriptorCount = 1,
|
||||||
.descriptorType = cast(layout->getBindings()[binding].descriptorType),
|
.descriptorType = cast(layout->getBindings()[binding].descriptorType),
|
||||||
.pImageInfo = &imageInfos.back(),
|
.pImageInfo = &imageInfos.back(),
|
||||||
});
|
});
|
||||||
|
|
||||||
boundResources[binding] = vulkanTexture->getHandle();
|
boundResources[binding][index] = vulkanTexture->getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorSet::updateTextureArray(uint32_t binding, Array<Gfx::PTexture2D> textures) {
|
void DescriptorSet::updateTexture(uint32_t binding, uint32 index, Gfx::PTexture3D texture) {
|
||||||
// maybe make this a parameter?
|
TextureBase* vulkanTexture = texture.cast<TextureBase>().getHandle();
|
||||||
uint32 arrayElement = 0;
|
if (boundResources[binding][index] == vulkanTexture->getHandle()) {
|
||||||
for (auto& gfxTexture : textures) {
|
return;
|
||||||
TextureBase* vulkanTexture = gfxTexture.cast<TextureBase>().getHandle();
|
|
||||||
if (boundResources[binding+arrayElement] == vulkanTexture->getHandle()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
imageInfos.add(VkDescriptorImageInfo{
|
|
||||||
.sampler = VK_NULL_HANDLE,
|
|
||||||
.imageView = vulkanTexture->getView(),
|
|
||||||
.imageLayout = cast(vulkanTexture->getLayout()),
|
|
||||||
});
|
|
||||||
|
|
||||||
boundResources[binding+arrayElement] = vulkanTexture->getHandle();
|
|
||||||
writeDescriptors.add(VkWriteDescriptorSet{
|
|
||||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
|
||||||
.pNext = nullptr,
|
|
||||||
.dstSet = setHandle,
|
|
||||||
.dstBinding = binding,
|
|
||||||
.dstArrayElement = arrayElement++,
|
|
||||||
.descriptorCount = 1,
|
|
||||||
.descriptorType = cast(layout->getBindings()[binding].descriptorType),
|
|
||||||
.pImageInfo = &imageInfos.back(),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// It is assumed that the image is in the correct layout
|
||||||
|
imageInfos.add(VkDescriptorImageInfo{
|
||||||
|
.sampler = VK_NULL_HANDLE,
|
||||||
|
.imageView = vulkanTexture->getView(),
|
||||||
|
.imageLayout = cast(vulkanTexture->getLayout()),
|
||||||
|
});
|
||||||
|
writeDescriptors.add(VkWriteDescriptorSet{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.dstSet = setHandle,
|
||||||
|
.dstBinding = binding,
|
||||||
|
.dstArrayElement = index,
|
||||||
|
.descriptorCount = 1,
|
||||||
|
.descriptorType = cast(layout->getBindings()[binding].descriptorType),
|
||||||
|
.pImageInfo = &imageInfos.back(),
|
||||||
|
});
|
||||||
|
|
||||||
|
boundResources[binding][index] = vulkanTexture->getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorSet::updateSamplerArray(uint32_t binding, Array<Gfx::PSampler> samplers) {
|
void DescriptorSet::updateTexture(uint32_t binding, uint32 index, Gfx::PTextureCube texture) {
|
||||||
// maybe make this a parameter?
|
TextureBase* vulkanTexture = texture.cast<TextureBase>().getHandle();
|
||||||
uint32 arrayElement = 0;
|
if (boundResources[binding][index] == vulkanTexture->getHandle()) {
|
||||||
for (auto& gfxSampler : samplers) {
|
return;
|
||||||
PSampler vulkanSampler = gfxSampler.cast<Sampler>();
|
|
||||||
if (boundResources[binding+arrayElement] == vulkanSampler->getHandle()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
imageInfos.add(VkDescriptorImageInfo{
|
|
||||||
.sampler = vulkanSampler->getHandle()->sampler,
|
|
||||||
.imageView = VK_NULL_HANDLE,
|
|
||||||
.imageLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
|
||||||
});
|
|
||||||
|
|
||||||
VkDescriptorType descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
|
|
||||||
boundResources[binding] = vulkanSampler->getHandle();
|
|
||||||
writeDescriptors.add(VkWriteDescriptorSet{
|
|
||||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
|
||||||
.pNext = nullptr,
|
|
||||||
.dstSet = setHandle,
|
|
||||||
.dstBinding = binding,
|
|
||||||
.dstArrayElement = arrayElement++,
|
|
||||||
.descriptorCount = 1,
|
|
||||||
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER,
|
|
||||||
.pImageInfo = &imageInfos.back(),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// It is assumed that the image is in the correct layout
|
||||||
|
imageInfos.add(VkDescriptorImageInfo{
|
||||||
|
.sampler = VK_NULL_HANDLE,
|
||||||
|
.imageView = vulkanTexture->getView(),
|
||||||
|
.imageLayout = cast(vulkanTexture->getLayout()),
|
||||||
|
});
|
||||||
|
writeDescriptors.add(VkWriteDescriptorSet{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.dstSet = setHandle,
|
||||||
|
.dstBinding = binding,
|
||||||
|
.dstArrayElement = index,
|
||||||
|
.descriptorCount = 1,
|
||||||
|
.descriptorType = cast(layout->getBindings()[binding].descriptorType),
|
||||||
|
.pImageInfo = &imageInfos.back(),
|
||||||
|
});
|
||||||
|
|
||||||
|
boundResources[binding][index] = vulkanTexture->getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorSet::updateAccelerationStructure(uint32 binding, Gfx::PTopLevelAS as) {
|
void DescriptorSet::updateAccelerationStructure(uint32 binding, uint32 index, Gfx::PTopLevelAS as) {
|
||||||
auto tlas = as.cast<TopLevelAS>();
|
auto tlas = as.cast<TopLevelAS>();
|
||||||
accelerationInfos.add(VkWriteDescriptorSetAccelerationStructureKHR{
|
accelerationInfos.add(VkWriteDescriptorSetAccelerationStructureKHR{
|
||||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR,
|
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR,
|
||||||
@@ -367,7 +362,7 @@ void DescriptorSet::updateAccelerationStructure(uint32 binding, Gfx::PTopLevelAS
|
|||||||
.pNext = &accelerationInfos.back(),
|
.pNext = &accelerationInfos.back(),
|
||||||
.dstSet = setHandle,
|
.dstSet = setHandle,
|
||||||
.dstBinding = binding,
|
.dstBinding = binding,
|
||||||
.dstArrayElement = 0,
|
.dstArrayElement = index,
|
||||||
.descriptorCount = 1,
|
.descriptorCount = 1,
|
||||||
.descriptorType = VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
|
.descriptorType = VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -48,14 +48,14 @@ class DescriptorSet : public Gfx::DescriptorSet, public CommandBoundResource {
|
|||||||
DescriptorSet(PGraphics graphics, PDescriptorPool owner);
|
DescriptorSet(PGraphics graphics, PDescriptorPool owner);
|
||||||
virtual ~DescriptorSet();
|
virtual ~DescriptorSet();
|
||||||
virtual void writeChanges() override;
|
virtual void writeChanges() override;
|
||||||
virtual void updateBuffer(uint32 binding, Gfx::PUniformBuffer uniformBuffer) override;
|
virtual void updateBuffer(uint32 binding, uint32 index, Gfx::PUniformBuffer uniformBuffer) override;
|
||||||
virtual void updateBuffer(uint32 binding, Gfx::PShaderBuffer uniformBuffer) override;
|
virtual void updateBuffer(uint32 binding, uint32 index, Gfx::PShaderBuffer shaderBuffer) override;
|
||||||
virtual void updateBuffer(uint32 binding, Gfx::PIndexBuffer uniformBuffer) override;
|
virtual void updateBuffer(uint32 binding, uint32 index, Gfx::PIndexBuffer indexBuffer) override;
|
||||||
virtual void updateSampler(uint32 binding, Gfx::PSampler samplerState) override;
|
virtual void updateSampler(uint32 binding, uint32 index, Gfx::PSampler samplerState) override;
|
||||||
virtual void updateTexture(uint32 binding, Gfx::PTexture texture, Gfx::PSampler sampler = nullptr) override;
|
virtual void updateTexture(uint32 binding, uint32 index, Gfx::PTexture2D texture) override;
|
||||||
virtual void updateTextureArray(uint32 binding, Array<Gfx::PTexture2D> texture) override;
|
virtual void updateTexture(uint32 binding, uint32 index, Gfx::PTexture3D texture) override;
|
||||||
virtual void updateSamplerArray(uint32 binding, Array<Gfx::PSampler> samplers) override;
|
virtual void updateTexture(uint32 binding, uint32 index, Gfx::PTextureCube texture) override;
|
||||||
virtual void updateAccelerationStructure(uint32 binding, Gfx::PTopLevelAS as) override;
|
virtual void updateAccelerationStructure(uint32 binding, uint32 index, Gfx::PTopLevelAS as) override;
|
||||||
|
|
||||||
constexpr VkDescriptorSet getHandle() const { return setHandle; }
|
constexpr VkDescriptorSet getHandle() const { return setHandle; }
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ class DescriptorSet : public Gfx::DescriptorSet, public CommandBoundResource {
|
|||||||
// since the layout is fixed, trying to bind a texture to a buffer
|
// since the layout is fixed, trying to bind a texture to a buffer
|
||||||
// would not work anyways, so casts should be safe
|
// would not work anyways, so casts should be safe
|
||||||
// Array<void*> cachedData;
|
// Array<void*> cachedData;
|
||||||
Array<PCommandBoundResource> boundResources;
|
Array<Array<PCommandBoundResource>> boundResources;
|
||||||
VkDescriptorSet setHandle;
|
VkDescriptorSet setHandle;
|
||||||
PGraphics graphics;
|
PGraphics graphics;
|
||||||
PDescriptorPool owner;
|
PDescriptorPool owner;
|
||||||
|
|||||||
@@ -114,9 +114,6 @@ Graphics::~Graphics() {
|
|||||||
|
|
||||||
void Graphics::init(GraphicsInitializer initInfo) {
|
void Graphics::init(GraphicsInitializer initInfo) {
|
||||||
initInstance(initInfo);
|
initInstance(initInfo);
|
||||||
#if ENABLE_VALIDATION
|
|
||||||
setupDebugCallback();
|
|
||||||
#endif
|
|
||||||
pickPhysicalDevice();
|
pickPhysicalDevice();
|
||||||
createDevice(initInfo);
|
createDevice(initInfo);
|
||||||
VmaAllocatorCreateInfo createInfo = {
|
VmaAllocatorCreateInfo createInfo = {
|
||||||
@@ -754,6 +751,7 @@ void Graphics::pickPhysicalDevice() {
|
|||||||
.storageBuffer8BitAccess = true,
|
.storageBuffer8BitAccess = true,
|
||||||
.uniformAndStorageBuffer8BitAccess = true,
|
.uniformAndStorageBuffer8BitAccess = true,
|
||||||
.shaderFloat16 = true,
|
.shaderFloat16 = true,
|
||||||
|
.shaderInt8 = true,
|
||||||
.shaderUniformBufferArrayNonUniformIndexing = true,
|
.shaderUniformBufferArrayNonUniformIndexing = true,
|
||||||
.shaderSampledImageArrayNonUniformIndexing = true,
|
.shaderSampledImageArrayNonUniformIndexing = true,
|
||||||
.shaderStorageBufferArrayNonUniformIndexing = true,
|
.shaderStorageBufferArrayNonUniformIndexing = true,
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ void Seele::beginCompilation(const ShaderCompilationInfo& info, SlangCompileTarg
|
|||||||
option[1].value.intValue0 = 1;
|
option[1].value.intValue0 = 1;
|
||||||
option[2].name = slang::CompilerOptionName::DebugInformation;
|
option[2].name = slang::CompilerOptionName::DebugInformation;
|
||||||
option[2].value.kind = slang::CompilerOptionValueKind::Int;
|
option[2].value.kind = slang::CompilerOptionValueKind::Int;
|
||||||
option[2].value.intValue0 = SLANG_DEBUG_INFO_LEVEL_NONE;
|
option[2].value.intValue0 = SLANG_DEBUG_INFO_LEVEL_STANDARD;
|
||||||
option[3].name = slang::CompilerOptionName::DebugInformationFormat;
|
option[3].name = slang::CompilerOptionName::DebugInformationFormat;
|
||||||
option[3].value.kind = slang::CompilerOptionValueKind::Int;
|
option[3].value.kind = slang::CompilerOptionValueKind::Int;
|
||||||
option[3].value.intValue0 = SLANG_DEBUG_INFO_FORMAT_PDB;
|
option[3].value.intValue0 = SLANG_DEBUG_INFO_FORMAT_PDB;
|
||||||
@@ -116,7 +116,7 @@ void Seele::beginCompilation(const ShaderCompilationInfo& info, SlangCompileTarg
|
|||||||
for (size_t i = 0; i < signature->getParameterCount(); ++i) {
|
for (size_t i = 0; i < signature->getParameterCount(); ++i) {
|
||||||
auto param = signature->getParameterByIndex(i);
|
auto param = signature->getParameterByIndex(i);
|
||||||
layout->addMapping(param->getName(), param->getBindingIndex());
|
layout->addMapping(param->getName(), param->getBindingIndex());
|
||||||
std::cout << param->getName() << ": " << param->getBindingIndex() << std::endl;
|
//std::cout << param->getName() << ": " << param->getBindingIndex() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// workaround
|
// workaround
|
||||||
|
|||||||
@@ -34,28 +34,28 @@ Material::Material(Gfx::PGraphics graphics, uint32 numTextures, uint32 numSample
|
|||||||
Material::~Material() {}
|
Material::~Material() {}
|
||||||
|
|
||||||
void Material::init(Gfx::PGraphics graphics) {
|
void Material::init(Gfx::PGraphics graphics) {
|
||||||
layout = graphics->createDescriptorLayout("pMaterial");
|
layout = graphics->createDescriptorLayout("pResources");
|
||||||
layout->addDescriptorBinding(Gfx::DescriptorBinding{
|
layout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||||
.binding = 0,
|
.binding = 0,
|
||||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
|
||||||
.descriptorCount = 1,
|
|
||||||
.bindingFlags = Gfx::SE_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT,
|
|
||||||
.shaderStages = Gfx::SE_SHADER_STAGE_FRAGMENT_BIT | Gfx::SE_SHADER_STAGE_CLOSEST_HIT_BIT_KHR,
|
|
||||||
});
|
|
||||||
layout->addDescriptorBinding(Gfx::DescriptorBinding{
|
|
||||||
.binding = 1,
|
|
||||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
||||||
.descriptorCount = 512,
|
.descriptorCount = 512,
|
||||||
.bindingFlags = Gfx::SE_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT,
|
.bindingFlags = Gfx::SE_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT,
|
||||||
.shaderStages = Gfx::SE_SHADER_STAGE_FRAGMENT_BIT | Gfx::SE_SHADER_STAGE_CLOSEST_HIT_BIT_KHR,
|
.shaderStages = Gfx::SE_SHADER_STAGE_FRAGMENT_BIT | Gfx::SE_SHADER_STAGE_CLOSEST_HIT_BIT_KHR,
|
||||||
});
|
});
|
||||||
layout->addDescriptorBinding(Gfx::DescriptorBinding{
|
layout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||||
.binding = 2,
|
.binding = 1,
|
||||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER,
|
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER,
|
||||||
.descriptorCount = 512,
|
.descriptorCount = 512,
|
||||||
.bindingFlags = Gfx::SE_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT,
|
.bindingFlags = Gfx::SE_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT,
|
||||||
.shaderStages = Gfx::SE_SHADER_STAGE_FRAGMENT_BIT | Gfx::SE_SHADER_STAGE_CLOSEST_HIT_BIT_KHR,
|
.shaderStages = Gfx::SE_SHADER_STAGE_FRAGMENT_BIT | Gfx::SE_SHADER_STAGE_CLOSEST_HIT_BIT_KHR,
|
||||||
});
|
});
|
||||||
|
layout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||||
|
.binding = 2,
|
||||||
|
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||||
|
.descriptorCount = 1,
|
||||||
|
.bindingFlags = Gfx::SE_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT,
|
||||||
|
.shaderStages = Gfx::SE_SHADER_STAGE_FRAGMENT_BIT | Gfx::SE_SHADER_STAGE_CLOSEST_HIT_BIT_KHR,
|
||||||
|
});
|
||||||
layout->create();
|
layout->create();
|
||||||
floatBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{
|
floatBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{
|
||||||
.dynamic = true,
|
.dynamic = true,
|
||||||
@@ -76,18 +76,17 @@ void Material::updateDescriptor() {
|
|||||||
Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||||
layout->reset();
|
layout->reset();
|
||||||
set = layout->allocateDescriptorSet();
|
set = layout->allocateDescriptorSet();
|
||||||
uint32 binding = 0;
|
|
||||||
set->updateBuffer(binding++, floatBuffer);
|
|
||||||
for (uint32 i = 0; i < textures.size(); ++i) {
|
for (uint32 i = 0; i < textures.size(); ++i) {
|
||||||
if (textures[i] != nullptr) {
|
if (textures[i] != nullptr) {
|
||||||
set->updateTexture(binding++, textures[i]);
|
set->updateTexture(0, i, textures[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (uint32 i = 0; i < samplers.size(); ++i) {
|
for (uint32 i = 0; i < samplers.size(); ++i) {
|
||||||
if (samplers[i] != nullptr) {
|
if (samplers[i] != nullptr) {
|
||||||
set->updateSampler(binding++, samplers[i]);
|
set->updateSampler(1, i, samplers[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
set->updateBuffer(2, 0, floatBuffer);
|
||||||
set->writeChanges();
|
set->writeChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,9 +62,9 @@ void LightEnvironment::commit() {
|
|||||||
Gfx::SE_ACCESS_SHADER_READ_BIT | Gfx::SE_ACCESS_TRANSFER_WRITE_BIT,
|
Gfx::SE_ACCESS_SHADER_READ_BIT | Gfx::SE_ACCESS_TRANSFER_WRITE_BIT,
|
||||||
Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT |
|
Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT |
|
||||||
Gfx::SE_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR | Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT);
|
Gfx::SE_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR | Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT);
|
||||||
set->updateBuffer(0, lightEnvBuffer);
|
set->updateBuffer(0, 0, lightEnvBuffer);
|
||||||
set->updateBuffer(1, directionalLights);
|
set->updateBuffer(1, 0, directionalLights);
|
||||||
set->updateBuffer(2, pointLights);
|
set->updateBuffer(2, 0, pointLights);
|
||||||
set->writeChanges();
|
set->writeChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreate
|
|||||||
renderGraph.addPass(new VisibilityPass(graphics, scene));
|
renderGraph.addPass(new VisibilityPass(graphics, scene));
|
||||||
renderGraph.addPass(new LightCullingPass(graphics, scene));
|
renderGraph.addPass(new LightCullingPass(graphics, scene));
|
||||||
renderGraph.addPass(new BasePass(graphics, scene));
|
renderGraph.addPass(new BasePass(graphics, scene));
|
||||||
renderGraph.addPass(new RayTracingPass(graphics, scene));
|
|
||||||
|
//renderGraph.addPass(new RayTracingPass(graphics, scene));
|
||||||
|
|
||||||
renderGraph.setViewport(viewport);
|
renderGraph.setViewport(viewport);
|
||||||
renderGraph.createRenderPass();
|
renderGraph.createRenderPass();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user