Initial environment loading (not working)
This commit is contained in:
@@ -0,0 +1,95 @@
|
|||||||
|
struct VertexOutput
|
||||||
|
{
|
||||||
|
float4 svPos : SV_Position;
|
||||||
|
float3 localPos : LOCALPOS;
|
||||||
|
};
|
||||||
|
const static float3 vertices[] = {
|
||||||
|
// Back
|
||||||
|
float3(-1, -1, 1),
|
||||||
|
float3(-1, 1, 1),
|
||||||
|
float3( 1, -1, 1),
|
||||||
|
|
||||||
|
float3( 1, -1, 1),
|
||||||
|
float3(-1, 1, 1),
|
||||||
|
float3( 1, 1, 1),
|
||||||
|
|
||||||
|
// Front
|
||||||
|
float3( 1, -1, -1),
|
||||||
|
float3( 1, 1, -1),
|
||||||
|
float3(-1, -1, -1),
|
||||||
|
|
||||||
|
float3(-1, -1, -1),
|
||||||
|
float3( 1, 1, -1),
|
||||||
|
float3(-1, 1, -1),
|
||||||
|
|
||||||
|
// Top
|
||||||
|
float3(-1, -1, -1),
|
||||||
|
float3(-1, -1, 1),
|
||||||
|
float3( 1, -1, -1),
|
||||||
|
|
||||||
|
float3( 1, -1, -1),
|
||||||
|
float3(-1, -1, 1),
|
||||||
|
float3( 1, -1, 1),
|
||||||
|
|
||||||
|
// Bottom
|
||||||
|
float3(-1, 1, 1),
|
||||||
|
float3(-1, 1, -1),
|
||||||
|
float3( 1, 1, 1),
|
||||||
|
|
||||||
|
float3( 1, 1, 1),
|
||||||
|
float3(-1, 1, -1),
|
||||||
|
float3( 1, 1, -1),
|
||||||
|
|
||||||
|
// Left
|
||||||
|
float3(-1, -1, -1),
|
||||||
|
float3(-1, 1, -1),
|
||||||
|
float3(-1, -1, 1),
|
||||||
|
|
||||||
|
float3(-1, -1, 1),
|
||||||
|
float3(-1, 1, -1),
|
||||||
|
float3(-1, 1, 1),
|
||||||
|
|
||||||
|
// Right
|
||||||
|
float3( 1, -1, 1),
|
||||||
|
float3( 1, 1, 1),
|
||||||
|
float3( 1, -1, -1),
|
||||||
|
|
||||||
|
float3( 1, -1, -1),
|
||||||
|
float3( 1, 1, 1),
|
||||||
|
float3( 1, 1, -1),
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ViewParams
|
||||||
|
{
|
||||||
|
float4x4 view[6];
|
||||||
|
float4x4 projection;
|
||||||
|
Texture2D equirectangularMap;
|
||||||
|
SamplerState sampler;
|
||||||
|
};
|
||||||
|
ParameterBlock<ViewParams> pViewParams;
|
||||||
|
|
||||||
|
[shader("vertex")]
|
||||||
|
VertexOutput vertMain(uint vertexIndex : SV_VertexID, uint viewIndex : SV_ViewID)
|
||||||
|
{
|
||||||
|
VertexOutput output;
|
||||||
|
output.localPos = vertices[vertexIndex + 6 * viewIndex];
|
||||||
|
output.svPos = mul(pViewParams.projection, mul(pViewParams.view[viewIndex], float4(vertices[vertexIndex], 1)));
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
const static float2 invAtan = float2(0.1591, 0.3183);
|
||||||
|
float2 sampleSphericalMap(float3 v)
|
||||||
|
{
|
||||||
|
float2 uv = float2(atan(v.z / v.x), asin(v.y));
|
||||||
|
uv *= invAtan;
|
||||||
|
uv += 0.5;
|
||||||
|
return uv;
|
||||||
|
}
|
||||||
|
|
||||||
|
[shader("fragment")]
|
||||||
|
float4 fragMain(float3 localPos : LOCALPOS) : SV_Target
|
||||||
|
{
|
||||||
|
float2 uv = sampleSphericalMap(normalize(localPos));
|
||||||
|
float3 color = pViewParams.equirectangularMap.Sample(pViewParams.sampler, uv).rgb;
|
||||||
|
return float4(color, 1);
|
||||||
|
}
|
||||||
@@ -12,11 +12,7 @@ struct SkyboxData
|
|||||||
};
|
};
|
||||||
ParameterBlock<SkyboxData> pSkyboxData;
|
ParameterBlock<SkyboxData> pSkyboxData;
|
||||||
|
|
||||||
[shader("vertex")]
|
const static float3 vertices[] = {
|
||||||
VertexShaderOutput vertexMain(
|
|
||||||
uint vertexIndex : SV_VertexId)
|
|
||||||
{
|
|
||||||
const float3 vertices[] = {
|
|
||||||
// Back
|
// Back
|
||||||
float3(-512, -512, 512),
|
float3(-512, -512, 512),
|
||||||
float3(-512, 512, 512),
|
float3(-512, 512, 512),
|
||||||
@@ -70,8 +66,12 @@ VertexShaderOutput vertexMain(
|
|||||||
float3( 512, -512, -512),
|
float3( 512, -512, -512),
|
||||||
float3( 512, 512, 512),
|
float3( 512, 512, 512),
|
||||||
float3( 512, 512, -512),
|
float3( 512, 512, -512),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[shader("vertex")]
|
||||||
|
VertexShaderOutput vertexMain(
|
||||||
|
uint vertexIndex : SV_VertexId)
|
||||||
|
{
|
||||||
VertexShaderOutput output;
|
VertexShaderOutput output;
|
||||||
float3x3 cameraRotation = float3x3(pViewParams.viewMatrix);
|
float3x3 cameraRotation = float3x3(pViewParams.viewMatrix);
|
||||||
float4 worldPos = float4(mul(cameraRotation, vertices[vertexIndex]), 1.0f);
|
float4 worldPos = float4(mul(cameraRotation, vertices[vertexIndex]), 1.0f);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include "MaterialLoader.h"
|
#include "MaterialLoader.h"
|
||||||
#include "MeshLoader.h"
|
#include "MeshLoader.h"
|
||||||
#include "TextureLoader.h"
|
#include "TextureLoader.h"
|
||||||
|
#include "EnvironmentLoader.h"
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
@@ -40,12 +40,21 @@ void AssetImporter::importMaterial(MaterialImportArgs args) {
|
|||||||
get().materialLoader->importAsset(args);
|
get().materialLoader->importAsset(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Seele::AssetImporter::importEnvironmentMap(EnvironmentImportArgs args) {
|
||||||
|
if (get().registry->getOrCreateFolder(args.importPath)->materials.contains(args.filePath.stem().string())) {
|
||||||
|
// skip importing duplicates
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
get().environmentLoader->importAsset(args);
|
||||||
|
}
|
||||||
|
|
||||||
void AssetImporter::init(Gfx::PGraphics graphics) {
|
void AssetImporter::init(Gfx::PGraphics graphics) {
|
||||||
get().registry = AssetRegistry::getInstance();
|
get().registry = AssetRegistry::getInstance();
|
||||||
get().meshLoader = new MeshLoader(graphics);
|
get().meshLoader = new MeshLoader(graphics);
|
||||||
get().textureLoader = new TextureLoader(graphics);
|
get().textureLoader = new TextureLoader(graphics);
|
||||||
get().materialLoader = new MaterialLoader(graphics);
|
get().materialLoader = new MaterialLoader(graphics);
|
||||||
get().fontLoader = new FontLoader(graphics);
|
get().fontLoader = new FontLoader(graphics);
|
||||||
|
get().environmentLoader = new EnvironmentLoader(graphics);
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetImporter& AssetImporter::get() {
|
AssetImporter& AssetImporter::get() {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Asset/AssetRegistry.h"
|
|
||||||
#include "MinimalEngine.h"
|
#include "MinimalEngine.h"
|
||||||
|
#include "Asset/AssetRegistry.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Seele {
|
namespace Seele {
|
||||||
@@ -8,12 +8,14 @@ DECLARE_REF(TextureLoader)
|
|||||||
DECLARE_REF(FontLoader)
|
DECLARE_REF(FontLoader)
|
||||||
DECLARE_REF(MeshLoader)
|
DECLARE_REF(MeshLoader)
|
||||||
DECLARE_REF(MaterialLoader)
|
DECLARE_REF(MaterialLoader)
|
||||||
|
DECLARE_REF(EnvironmentLoader)
|
||||||
class AssetImporter {
|
class AssetImporter {
|
||||||
public:
|
public:
|
||||||
static void importMesh(struct MeshImportArgs args);
|
static void importMesh(struct MeshImportArgs args);
|
||||||
static void importTexture(struct TextureImportArgs args);
|
static void importTexture(struct TextureImportArgs args);
|
||||||
static void importFont(struct FontImportArgs args);
|
static void importFont(struct FontImportArgs args);
|
||||||
static void importMaterial(struct MaterialImportArgs args);
|
static void importMaterial(struct MaterialImportArgs args);
|
||||||
|
static void importEnvironmentMap(struct EnvironmentImportArgs args);
|
||||||
static void init(Gfx::PGraphics graphics);
|
static void init(Gfx::PGraphics graphics);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -22,6 +24,7 @@ class AssetImporter {
|
|||||||
UPFontLoader fontLoader;
|
UPFontLoader fontLoader;
|
||||||
UPMeshLoader meshLoader;
|
UPMeshLoader meshLoader;
|
||||||
UPMaterialLoader materialLoader;
|
UPMaterialLoader materialLoader;
|
||||||
|
UPEnvironmentLoader environmentLoader;
|
||||||
AssetRegistry* registry;
|
AssetRegistry* registry;
|
||||||
};
|
};
|
||||||
} // namespace Seele
|
} // namespace Seele
|
||||||
@@ -2,6 +2,8 @@ target_sources(Editor
|
|||||||
PRIVATE
|
PRIVATE
|
||||||
AssetImporter.h
|
AssetImporter.h
|
||||||
AssetImporter.cpp
|
AssetImporter.cpp
|
||||||
|
EnvironmentLoader.h
|
||||||
|
EnvironmentLoader.cpp
|
||||||
FontLoader.h
|
FontLoader.h
|
||||||
FontLoader.cpp
|
FontLoader.cpp
|
||||||
MaterialLoader.h
|
MaterialLoader.h
|
||||||
|
|||||||
@@ -0,0 +1,147 @@
|
|||||||
|
#include "EnvironmentLoader.h"
|
||||||
|
#include "Asset/AssetRegistry.h"
|
||||||
|
#include "Asset/EnvironmentMapAsset.h"
|
||||||
|
#include "Graphics/Descriptor.h"
|
||||||
|
#include "stb_image.h"
|
||||||
|
|
||||||
|
using namespace Seele;
|
||||||
|
|
||||||
|
EnvironmentLoader::EnvironmentLoader(Gfx::PGraphics graphics) : graphics(graphics) {
|
||||||
|
cubeRenderViewport = graphics->createViewport(nullptr, ViewportCreateInfo{
|
||||||
|
.dimensions =
|
||||||
|
{
|
||||||
|
.size = {1024, 1024},
|
||||||
|
.offset = {0, 0},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
cubeRenderLayout = graphics->createDescriptorLayout("pViewParams");
|
||||||
|
cubeRenderLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||||
|
.name = "view",
|
||||||
|
.uniformLength = sizeof(Matrix4) * 6,
|
||||||
|
});
|
||||||
|
cubeRenderLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||||
|
.name = "projection",
|
||||||
|
.uniformLength = sizeof(Matrix4),
|
||||||
|
});
|
||||||
|
cubeRenderLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||||
|
.name = "equirectangularMap",
|
||||||
|
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
||||||
|
});
|
||||||
|
cubeRenderLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||||
|
.name = "sampler",
|
||||||
|
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER,
|
||||||
|
});
|
||||||
|
cubeRenderLayout->create();
|
||||||
|
|
||||||
|
cubePipelineLayout = graphics->createPipelineLayout("CubeRenderLayout");
|
||||||
|
cubePipelineLayout->addDescriptorLayout(cubeRenderLayout);
|
||||||
|
|
||||||
|
graphics->beginShaderCompilation(ShaderCompilationInfo{
|
||||||
|
.name = "CubeRenderPipeline",
|
||||||
|
.modules = {"EnvironmentMapping"},
|
||||||
|
.entryPoints =
|
||||||
|
{
|
||||||
|
{"vertMain", "EnvironmentMapping"},
|
||||||
|
{"fragMain", "EnvironmentMapping"},
|
||||||
|
},
|
||||||
|
.rootSignature = cubePipelineLayout,
|
||||||
|
});
|
||||||
|
cubePipelineLayout->create();
|
||||||
|
|
||||||
|
cubeRenderVertex = graphics->createVertexShader({0});
|
||||||
|
cubeRenderFrag = graphics->createFragmentShader({1});
|
||||||
|
|
||||||
|
cubeSampler = graphics->createSampler({
|
||||||
|
.magFilter = Gfx::SE_FILTER_LINEAR,
|
||||||
|
.minFilter = Gfx::SE_FILTER_LINEAR,
|
||||||
|
.addressModeU = Gfx::SE_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||||
|
.addressModeV = Gfx::SE_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||||
|
.addressModeW = Gfx::SE_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
EnvironmentLoader::~EnvironmentLoader() {}
|
||||||
|
|
||||||
|
void EnvironmentLoader::importAsset(EnvironmentImportArgs args) {
|
||||||
|
std::filesystem::path assetPath = args.filePath.filename();
|
||||||
|
assetPath.replace_extension("asset");
|
||||||
|
OEnvironmentMapAsset asset = new EnvironmentMapAsset(args.importPath, assetPath.stem().string());
|
||||||
|
asset->setStatus(Asset::Status::Loading);
|
||||||
|
// the registry takes ownership, but we need to edit the reference
|
||||||
|
PEnvironmentMapAsset ref = asset;
|
||||||
|
AssetRegistry::get().registerEnvironmentMap(std::move(asset));
|
||||||
|
import(args, ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EnvironmentLoader::import(EnvironmentImportArgs args, PEnvironmentMapAsset asset) {
|
||||||
|
stbi_set_flip_vertically_on_load(true);
|
||||||
|
int width, height, nrComponents;
|
||||||
|
float* data = stbi_loadf(args.filePath.string().c_str(), &width, &height, &nrComponents, 4);
|
||||||
|
stbi_set_flip_vertically_on_load(false);
|
||||||
|
assert(data);
|
||||||
|
Gfx::OTexture2D hdrTexture = graphics->createTexture2D(TextureCreateInfo{
|
||||||
|
.sourceData =
|
||||||
|
{
|
||||||
|
.size = width * height * 4 * sizeof(float),
|
||||||
|
.data = (uint8*)data,
|
||||||
|
},
|
||||||
|
.format = Gfx::SE_FORMAT_R32G32B32A32_SFLOAT,
|
||||||
|
.width = (uint32)width,
|
||||||
|
.height = (uint32)height,
|
||||||
|
.name = "HDRRaw",
|
||||||
|
});
|
||||||
|
Matrix4 captureProjection = glm::perspective(glm::radians(90.0f), 1.0f, 0.1f, 10.0f);
|
||||||
|
Matrix4 captureViews[] = {
|
||||||
|
glm::lookAt(Vector(0.0f, 0.0f, 0.0f), Vector(0.0f, 0.0f, 1.0f), Vector(0.0f, 1.0f, 0.0f)),
|
||||||
|
glm::lookAt(Vector(0.0f, 0.0f, 0.0f), Vector(0.0f, 0.0f, -1.0f), Vector(0.0f, 1.0f, 0.0f)),
|
||||||
|
glm::lookAt(Vector(0.0f, 0.0f, 0.0f), Vector(0.0f, -1.0f, 0.0f), Vector(1.0f, 0.0f, 0.0f)),
|
||||||
|
glm::lookAt(Vector(0.0f, 0.0f, 0.0f), Vector(0.0f, 1.0f, 0.0f), Vector(1.0f, 0.0f, 0.0f)),
|
||||||
|
glm::lookAt(Vector(0.0f, 0.0f, 0.0f), Vector(-1.0f, 0.0f, 0.0f), Vector(0.0f, 1.0f, 0.0f)),
|
||||||
|
glm::lookAt(Vector(0.0f, 0.0f, 0.0f), Vector(1.0f, 0.0f, 0.0f), Vector(0.0f, 1.0f, 0.0f)),
|
||||||
|
};
|
||||||
|
Gfx::PDescriptorSet set = cubeRenderLayout->allocateDescriptorSet();
|
||||||
|
set->updateConstants("view", 0, captureViews);
|
||||||
|
set->updateConstants("projection", 0, &captureProjection);
|
||||||
|
set->updateTexture("equirectangularMap", 0, Gfx::PTexture2D(hdrTexture));
|
||||||
|
set->updateSampler("sampler", 0, cubeSampler);
|
||||||
|
set->writeChanges();
|
||||||
|
Gfx::OTextureCube cubeMap = graphics->createTextureCube(TextureCreateInfo{
|
||||||
|
.format = Gfx::SE_FORMAT_R32G32B32A32_SFLOAT,
|
||||||
|
.width = 1024,
|
||||||
|
.height = 1024,
|
||||||
|
.usage = Gfx::SE_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
|
||||||
|
});
|
||||||
|
cubeRenderPass = graphics->createRenderPass(
|
||||||
|
Gfx::RenderTargetLayout{
|
||||||
|
.colorAttachments = {Gfx::RenderTargetAttachment(cubeMap, Gfx::SE_IMAGE_LAYOUT_UNDEFINED,
|
||||||
|
Gfx::SE_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||||
|
Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_STORE)},
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
URect{
|
||||||
|
.size = {1024, 1024},
|
||||||
|
.offset = {0, 0},
|
||||||
|
},
|
||||||
|
"EnvironmentRenderPass", {0b111111}, {0b111111});
|
||||||
|
cubeRenderPipeline = graphics->createGraphicsPipeline(Gfx::LegacyPipelineCreateInfo{
|
||||||
|
.vertexShader = cubeRenderVertex,
|
||||||
|
.fragmentShader = cubeRenderFrag,
|
||||||
|
.renderPass = cubeRenderPass,
|
||||||
|
.pipelineLayout = cubePipelineLayout,
|
||||||
|
.colorBlend =
|
||||||
|
{
|
||||||
|
.attachmentCount = 1,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
graphics->beginRenderPass(cubeRenderPass);
|
||||||
|
Gfx::ORenderCommand renderCommand = graphics->createRenderCommand("CubeMapRender");
|
||||||
|
renderCommand->bindPipeline(cubeRenderPipeline);
|
||||||
|
renderCommand->bindDescriptor({set});
|
||||||
|
renderCommand->setViewport(cubeRenderViewport);
|
||||||
|
renderCommand->draw(6, 1, 0, 0);
|
||||||
|
graphics->executeCommands(std::move(renderCommand));
|
||||||
|
graphics->endRenderPass();
|
||||||
|
graphics->waitDeviceIdle();
|
||||||
|
asset->diffuseMap = std::move(cubeMap);
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "MinimalEngine.h"
|
||||||
|
#include "Graphics/Graphics.h"
|
||||||
|
#include "Graphics/Shader.h"
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
|
namespace Seele
|
||||||
|
{
|
||||||
|
DECLARE_REF(EnvironmentMapAsset)
|
||||||
|
struct EnvironmentImportArgs {
|
||||||
|
std::filesystem::path filePath;
|
||||||
|
std::string importPath;
|
||||||
|
};
|
||||||
|
class EnvironmentLoader {
|
||||||
|
public:
|
||||||
|
EnvironmentLoader(Gfx::PGraphics graphic);
|
||||||
|
~EnvironmentLoader();
|
||||||
|
void importAsset(EnvironmentImportArgs args);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void import(EnvironmentImportArgs args, PEnvironmentMapAsset asset);
|
||||||
|
Gfx::PGraphics graphics;
|
||||||
|
Gfx::OVertexShader cubeRenderVertex;
|
||||||
|
Gfx::OFragmentShader cubeRenderFrag;
|
||||||
|
Gfx::ODescriptorLayout cubeRenderLayout;
|
||||||
|
Gfx::OPipelineLayout cubePipelineLayout;
|
||||||
|
Gfx::PGraphicsPipeline cubeRenderPipeline;
|
||||||
|
Gfx::ORenderPass cubeRenderPass;
|
||||||
|
Gfx::OViewport cubeRenderViewport;
|
||||||
|
Gfx::OSampler cubeSampler;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "Asset/MaterialLoader.h"
|
#include "Asset/MaterialLoader.h"
|
||||||
#include "Asset/MeshLoader.h"
|
#include "Asset/MeshLoader.h"
|
||||||
#include "Asset/TextureLoader.h"
|
#include "Asset/TextureLoader.h"
|
||||||
|
#include "Asset/EnvironmentLoader.h"
|
||||||
#include "Graphics/Initializer.h"
|
#include "Graphics/Initializer.h"
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include "Graphics/Metal/Graphics.h"
|
#include "Graphics/Metal/Graphics.h"
|
||||||
@@ -99,6 +100,9 @@ int main() {
|
|||||||
.filePath = sourcePath / "import/textures/skybox.jpg",
|
.filePath = sourcePath / "import/textures/skybox.jpg",
|
||||||
.type = TextureImportType::TEXTURE_CUBEMAP,
|
.type = TextureImportType::TEXTURE_CUBEMAP,
|
||||||
});
|
});
|
||||||
|
AssetImporter::importEnvironmentMap(EnvironmentImportArgs{
|
||||||
|
.filePath = sourcePath / "import/models/main1_sponza/textures/kloppenheim_05_4k.hdr",
|
||||||
|
});
|
||||||
// AssetImporter::importMesh(MeshImportArgs{
|
// AssetImporter::importMesh(MeshImportArgs{
|
||||||
// .filePath = sourcePath / "import/models/ship.fbx",
|
// .filePath = sourcePath / "import/models/ship.fbx",
|
||||||
// .importPath = "ship",
|
// .importPath = "ship",
|
||||||
|
|||||||
@@ -1,18 +1,14 @@
|
|||||||
#include "AssetRegistry.h"
|
#include "AssetRegistry.h"
|
||||||
|
#include "Asset/FontAsset.h"
|
||||||
|
#include "Asset/MaterialAsset.h"
|
||||||
|
#include "Asset/MaterialInstanceAsset.h"
|
||||||
|
#include "Asset/MeshAsset.h"
|
||||||
|
#include "Asset/EnvironmentMapAsset.h"
|
||||||
|
#include "Asset/SVGAsset.h"
|
||||||
|
#include "Asset/TextureAsset.h"
|
||||||
#include "FontAsset.h"
|
#include "FontAsset.h"
|
||||||
#include "Graphics/Graphics.h"
|
#include "Graphics/Graphics.h"
|
||||||
#include "Graphics/Mesh.h"
|
#include "Graphics/Mesh.h"
|
||||||
#include "MaterialAsset.h"
|
|
||||||
#include "MaterialInstanceAsset.h"
|
|
||||||
#include "MeshAsset.h"
|
|
||||||
#include "SVGAsset.h"
|
|
||||||
#include "TextureAsset.h"
|
|
||||||
#include "Asset/TextureAsset.h"
|
|
||||||
#include "Asset/FontAsset.h"
|
|
||||||
#include "Asset/SVGAsset.h"
|
|
||||||
#include "Asset/MeshAsset.h"
|
|
||||||
#include "Asset/MaterialAsset.h"
|
|
||||||
#include "Asset/MaterialInstanceAsset.h"
|
|
||||||
#include "Window/WindowManager.h"
|
#include "Window/WindowManager.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -62,6 +58,15 @@ PSVGAsset AssetRegistry::findSVG(std::string_view folderPath, std::string_view f
|
|||||||
return folder->svgs.at(std::string(filePath));
|
return folder->svgs.at(std::string(filePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PEnvironmentMapAsset AssetRegistry::findEnvironmentMap(std::string_view folderPath, std::string_view filePath) {
|
||||||
|
std::unique_lock l(get().assetLock);
|
||||||
|
AssetFolder* folder = get().assetRoot;
|
||||||
|
if (!folderPath.empty()) {
|
||||||
|
folder = get().getOrCreateFolder(folderPath);
|
||||||
|
}
|
||||||
|
return folder->envs.at(std::string(filePath));
|
||||||
|
}
|
||||||
|
|
||||||
PMaterialAsset AssetRegistry::findMaterial(std::string_view folderPath, std::string_view filePath) {
|
PMaterialAsset AssetRegistry::findMaterial(std::string_view folderPath, std::string_view filePath) {
|
||||||
std::unique_lock l(get().assetLock);
|
std::unique_lock l(get().assetLock);
|
||||||
AssetFolder* folder = get().assetRoot;
|
AssetFolder* folder = get().assetRoot;
|
||||||
@@ -100,6 +105,11 @@ void AssetRegistry::registerSVG(OSVGAsset svg) {
|
|||||||
get().registerSVGInternal(std::move(svg));
|
get().registerSVGInternal(std::move(svg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AssetRegistry::registerEnvironmentMap(OEnvironmentMapAsset env) {
|
||||||
|
std::unique_lock l(get().assetLock);
|
||||||
|
get().registerEnvironmentMapInternal(std::move(env));
|
||||||
|
}
|
||||||
|
|
||||||
void AssetRegistry::registerMaterial(OMaterialAsset material) {
|
void AssetRegistry::registerMaterial(OMaterialAsset material) {
|
||||||
std::unique_lock l(get().assetLock);
|
std::unique_lock l(get().assetLock);
|
||||||
get().registerMaterialInternal(std::move(material));
|
get().registerMaterialInternal(std::move(material));
|
||||||
@@ -152,6 +162,9 @@ void AssetRegistry::loadAsset(ArchiveBuffer& buffer) {
|
|||||||
case SVGAsset::IDENTIFIER:
|
case SVGAsset::IDENTIFIER:
|
||||||
asset = PSVGAsset(folder->svgs.at(name));
|
asset = PSVGAsset(folder->svgs.at(name));
|
||||||
break;
|
break;
|
||||||
|
case EnvironmentMapAsset::IDENTIFIER:
|
||||||
|
asset = PEnvironmentMapAsset(folder->envs.at(name));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new std::logic_error("Unknown Identifier");
|
throw new std::logic_error("Unknown Identifier");
|
||||||
}
|
}
|
||||||
@@ -182,13 +195,9 @@ AssetRegistry::AssetRegistry() : assetRoot(nullptr) {}
|
|||||||
|
|
||||||
AssetRegistry* AssetRegistry::getInstance() { return _instance; }
|
AssetRegistry* AssetRegistry::getInstance() { return _instance; }
|
||||||
|
|
||||||
void AssetRegistry::loadRegistry() {
|
void AssetRegistry::loadRegistry() { get().loadRegistryInternal(); }
|
||||||
get().loadRegistryInternal();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AssetRegistry::saveRegistry() {
|
void AssetRegistry::saveRegistry() { get().saveRegistryInternal(); }
|
||||||
get().saveRegistryInternal();
|
|
||||||
}
|
|
||||||
|
|
||||||
AssetRegistry::AssetFolder* AssetRegistry::getOrCreateFolder(std::string_view fullPath) {
|
AssetRegistry::AssetFolder* AssetRegistry::getOrCreateFolder(std::string_view fullPath) {
|
||||||
AssetFolder* result = assetRoot;
|
AssetFolder* result = assetRoot;
|
||||||
@@ -301,13 +310,16 @@ Pair<PAsset, ArchiveBuffer> AssetRegistry::peekAsset(ArchiveBuffer& buffer) {
|
|||||||
folder->svgs[name] = new SVGAsset(folderPath, name);
|
folder->svgs[name] = new SVGAsset(folderPath, name);
|
||||||
asset = PSVGAsset(folder->svgs[name]);
|
asset = PSVGAsset(folder->svgs[name]);
|
||||||
break;
|
break;
|
||||||
|
case EnvironmentMapAsset::IDENTIFIER:
|
||||||
|
folder->envs[name] = new EnvironmentMapAsset(folderPath, name);
|
||||||
|
asset = PEnvironmentMapAsset(folder->envs[name]);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new std::logic_error("Unknown Identifier");
|
throw new std::logic_error("Unknown Identifier");
|
||||||
}
|
}
|
||||||
return {asset, std::move(buffer)};
|
return {asset, std::move(buffer)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AssetRegistry::saveRegistryInternal() { saveFolder("", assetRoot); }
|
void AssetRegistry::saveRegistryInternal() { saveFolder("", assetRoot); }
|
||||||
|
|
||||||
void AssetRegistry::saveFolder(const std::filesystem::path& folderPath, AssetFolder* folder) {
|
void AssetRegistry::saveFolder(const std::filesystem::path& folderPath, AssetFolder* folder) {
|
||||||
@@ -330,6 +342,9 @@ void AssetRegistry::saveFolder(const std::filesystem::path& folderPath, AssetFol
|
|||||||
for (const auto& [name, svg] : folder->svgs) {
|
for (const auto& [name, svg] : folder->svgs) {
|
||||||
saveAsset(PSVGAsset(svg), SVGAsset::IDENTIFIER, folderPath, name);
|
saveAsset(PSVGAsset(svg), SVGAsset::IDENTIFIER, folderPath, name);
|
||||||
}
|
}
|
||||||
|
for (const auto& [name, env] : folder->envs) {
|
||||||
|
saveAsset(PEnvironmentMapAsset(env), EnvironmentMapAsset::IDENTIFIER, folderPath, name);
|
||||||
|
}
|
||||||
for (auto& [name, child] : folder->children) {
|
for (auto& [name, child] : folder->children) {
|
||||||
saveFolder(folderPath / name, child);
|
saveFolder(folderPath / name, child);
|
||||||
}
|
}
|
||||||
@@ -357,6 +372,11 @@ void AssetRegistry::registerSVGInternal(OSVGAsset svg) {
|
|||||||
folder->svgs[svg->getName()] = std::move(svg);
|
folder->svgs[svg->getName()] = std::move(svg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AssetRegistry::registerEnvironmentMapInternal(OEnvironmentMapAsset env) {
|
||||||
|
AssetFolder* folder = getOrCreateFolder(env->getFolderPath());
|
||||||
|
folder->envs[env->getName()] = std::move(env);
|
||||||
|
}
|
||||||
|
|
||||||
void AssetRegistry::registerMaterialInternal(OMaterialAsset material) {
|
void AssetRegistry::registerMaterialInternal(OMaterialAsset material) {
|
||||||
AssetFolder* folder = getOrCreateFolder(material->getFolderPath());
|
AssetFolder* folder = getOrCreateFolder(material->getFolderPath());
|
||||||
folder->materials[material->getName()] = std::move(material);
|
folder->materials[material->getName()] = std::move(material);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ DECLARE_REF(TextureAsset)
|
|||||||
DECLARE_REF(FontAsset)
|
DECLARE_REF(FontAsset)
|
||||||
DECLARE_REF(SVGAsset)
|
DECLARE_REF(SVGAsset)
|
||||||
DECLARE_REF(MeshAsset)
|
DECLARE_REF(MeshAsset)
|
||||||
|
DECLARE_REF(EnvironmentMapAsset)
|
||||||
DECLARE_REF(MaterialAsset)
|
DECLARE_REF(MaterialAsset)
|
||||||
DECLARE_REF(MaterialInstanceAsset)
|
DECLARE_REF(MaterialInstanceAsset)
|
||||||
DECLARE_NAME_REF(Gfx, Graphics)
|
DECLARE_NAME_REF(Gfx, Graphics)
|
||||||
@@ -26,6 +27,7 @@ class AssetRegistry {
|
|||||||
static PTextureAsset findTexture(std::string_view folderPath, std::string_view filePath);
|
static PTextureAsset findTexture(std::string_view folderPath, std::string_view filePath);
|
||||||
static PFontAsset findFont(std::string_view folderPath, std::string_view name);
|
static PFontAsset findFont(std::string_view folderPath, std::string_view name);
|
||||||
static PSVGAsset findSVG(std::string_view folderPath, std::string_view name);
|
static PSVGAsset findSVG(std::string_view folderPath, std::string_view name);
|
||||||
|
static PEnvironmentMapAsset findEnvironmentMap(std::string_view folder, std::string_view name);
|
||||||
static PMaterialAsset findMaterial(std::string_view folderPath, std::string_view filePath);
|
static PMaterialAsset findMaterial(std::string_view folderPath, std::string_view filePath);
|
||||||
static PMaterialInstanceAsset findMaterialInstance(std::string_view folderPath, std::string_view filePath);
|
static PMaterialInstanceAsset findMaterialInstance(std::string_view folderPath, std::string_view filePath);
|
||||||
|
|
||||||
@@ -33,6 +35,7 @@ class AssetRegistry {
|
|||||||
static void registerTexture(OTextureAsset texture);
|
static void registerTexture(OTextureAsset texture);
|
||||||
static void registerFont(OFontAsset font);
|
static void registerFont(OFontAsset font);
|
||||||
static void registerSVG(OSVGAsset svg);
|
static void registerSVG(OSVGAsset svg);
|
||||||
|
static void registerEnvironmentMap(OEnvironmentMapAsset env);
|
||||||
static void registerMaterial(OMaterialAsset material);
|
static void registerMaterial(OMaterialAsset material);
|
||||||
static void registerMaterialInstance(OMaterialInstanceAsset instance);
|
static void registerMaterialInstance(OMaterialInstanceAsset instance);
|
||||||
|
|
||||||
@@ -52,6 +55,7 @@ class AssetRegistry {
|
|||||||
Map<std::string, OTextureAsset> textures;
|
Map<std::string, OTextureAsset> textures;
|
||||||
Map<std::string, OFontAsset> fonts;
|
Map<std::string, OFontAsset> fonts;
|
||||||
Map<std::string, OSVGAsset> svgs;
|
Map<std::string, OSVGAsset> svgs;
|
||||||
|
Map<std::string, OEnvironmentMapAsset> envs;
|
||||||
Map<std::string, OMeshAsset> meshes;
|
Map<std::string, OMeshAsset> meshes;
|
||||||
Map<std::string, OMaterialAsset> materials;
|
Map<std::string, OMaterialAsset> materials;
|
||||||
Map<std::string, OMaterialInstanceAsset> instances;
|
Map<std::string, OMaterialInstanceAsset> instances;
|
||||||
@@ -75,6 +79,7 @@ class AssetRegistry {
|
|||||||
void registerTextureInternal(OTextureAsset texture);
|
void registerTextureInternal(OTextureAsset texture);
|
||||||
void registerFontInternal(OFontAsset font);
|
void registerFontInternal(OFontAsset font);
|
||||||
void registerSVGInternal(OSVGAsset svg);
|
void registerSVGInternal(OSVGAsset svg);
|
||||||
|
void registerEnvironmentMapInternal(OEnvironmentMapAsset env);
|
||||||
void registerMaterialInternal(OMaterialAsset material);
|
void registerMaterialInternal(OMaterialAsset material);
|
||||||
void registerMaterialInstanceInternal(OMaterialInstanceAsset instance);
|
void registerMaterialInstanceInternal(OMaterialInstanceAsset instance);
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ target_sources(Engine
|
|||||||
Asset.cpp
|
Asset.cpp
|
||||||
AssetRegistry.h
|
AssetRegistry.h
|
||||||
AssetRegistry.cpp
|
AssetRegistry.cpp
|
||||||
|
EnvironmentMapAsset.h
|
||||||
|
EnvironmentMapAsset.cpp
|
||||||
FontAsset.h
|
FontAsset.h
|
||||||
FontAsset.cpp
|
FontAsset.cpp
|
||||||
LevelAsset.h
|
LevelAsset.h
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#include "EnvironmentMapAsset.h"
|
||||||
|
|
||||||
|
using namespace Seele;
|
||||||
|
|
||||||
|
EnvironmentMapAsset::EnvironmentMapAsset() {}
|
||||||
|
|
||||||
|
EnvironmentMapAsset::EnvironmentMapAsset(std::string_view folderPath, std::string_view name) : Asset(folderPath, name) {}
|
||||||
|
|
||||||
|
EnvironmentMapAsset::~EnvironmentMapAsset() {}
|
||||||
|
|
||||||
|
void EnvironmentMapAsset::save(ArchiveBuffer& buffer) const {}
|
||||||
|
|
||||||
|
void EnvironmentMapAsset::load(ArchiveBuffer& buffer) {}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Asset.h"
|
||||||
|
#include "Graphics/Texture.h"
|
||||||
|
|
||||||
|
namespace Seele {
|
||||||
|
class EnvironmentMapAsset : public Asset {
|
||||||
|
public:
|
||||||
|
static constexpr uint64 IDENTIFIER = 0x80;
|
||||||
|
EnvironmentMapAsset();
|
||||||
|
EnvironmentMapAsset(std::string_view folderPath, std::string_view name);
|
||||||
|
virtual ~EnvironmentMapAsset();
|
||||||
|
virtual void save(ArchiveBuffer& buffer) const override;
|
||||||
|
virtual void load(ArchiveBuffer& buffer) override;
|
||||||
|
private:
|
||||||
|
Gfx::OTextureCube diffuseMap;
|
||||||
|
Gfx::OTextureCube specularMap;
|
||||||
|
friend class EnvironmentLoader;
|
||||||
|
};
|
||||||
|
} // namespace Seele
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
namespace Seele {
|
namespace Seele {
|
||||||
class LevelAsset : public Asset {
|
class LevelAsset : public Asset {
|
||||||
public:
|
public:
|
||||||
static constexpr uint64 IDENTIFIER = 0x20;
|
static constexpr uint64 IDENTIFIER = 0x40;
|
||||||
LevelAsset();
|
LevelAsset();
|
||||||
LevelAsset(std::string_view folderPath, std::string_view name);
|
LevelAsset(std::string_view folderPath, std::string_view name);
|
||||||
virtual ~LevelAsset();
|
virtual ~LevelAsset();
|
||||||
|
|||||||
@@ -30,6 +30,6 @@ PMaterialInstanceAsset MaterialAsset::instantiate(const InstantiationParameter&
|
|||||||
asset->setBase(this);
|
asset->setBase(this);
|
||||||
PMaterialInstanceAsset ref = asset;
|
PMaterialInstanceAsset ref = asset;
|
||||||
AssetRegistry::registerMaterialInstance(std::move(asset));
|
AssetRegistry::registerMaterialInstance(std::move(asset));
|
||||||
AssetRegistry::saveAsset(ref, MaterialInstanceAsset::IDENTIFIER, ref->getFolderPath(), ref->getName());
|
AssetRegistry::saveAsset(PAsset(ref), MaterialInstanceAsset::IDENTIFIER, ref->getFolderPath(), ref->getName());
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,9 +68,7 @@ class DescriptorSet {
|
|||||||
virtual void updateBuffer(const std::string& name, uint32 index, Gfx::PVertexBuffer indexBuffer) = 0;
|
virtual void updateBuffer(const std::string& name, uint32 index, Gfx::PVertexBuffer indexBuffer) = 0;
|
||||||
virtual void updateBuffer(const std::string& name, uint32 index, Gfx::PIndexBuffer indexBuffer) = 0;
|
virtual void updateBuffer(const std::string& name, uint32 index, Gfx::PIndexBuffer indexBuffer) = 0;
|
||||||
virtual void updateSampler(const std::string& name, uint32 index, Gfx::PSampler samplerState) = 0;
|
virtual void updateSampler(const std::string& name, uint32 index, Gfx::PSampler samplerState) = 0;
|
||||||
virtual void updateTexture(const std::string& name, uint32 index, Gfx::PTexture2D texture) = 0;
|
virtual void updateTexture(const std::string& name, uint32 index, Gfx::PTexture texture) = 0;
|
||||||
virtual void updateTexture(const std::string& name, uint32 index, Gfx::PTexture3D texture) = 0;
|
|
||||||
virtual void updateTexture(const std::string& name, uint32 index, Gfx::PTextureCube texture) = 0;
|
|
||||||
virtual void updateAccelerationStructure(const std::string& name, uint32 index, Gfx::PTopLevelAS as) = 0;
|
virtual void updateAccelerationStructure(const std::string& name, uint32 index, Gfx::PTopLevelAS as) = 0;
|
||||||
bool operator<(PDescriptorSet other);
|
bool operator<(PDescriptorSet other);
|
||||||
|
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ class Graphics {
|
|||||||
virtual OWindow createWindow(const WindowCreateInfo& createInfo) = 0;
|
virtual OWindow createWindow(const WindowCreateInfo& createInfo) = 0;
|
||||||
virtual OViewport createViewport(PWindow owner, const ViewportCreateInfo& createInfo) = 0;
|
virtual OViewport createViewport(PWindow owner, const ViewportCreateInfo& createInfo) = 0;
|
||||||
|
|
||||||
virtual ORenderPass createRenderPass(RenderTargetLayout layout, Array<SubPassDependency> dependencies, PViewport renderArea,
|
virtual ORenderPass createRenderPass(RenderTargetLayout layout, Array<SubPassDependency> dependencies, URect renderArea,
|
||||||
std::string name = "") = 0;
|
std::string name = "", Array<uint32> viewMasks = {}, Array<uint32> correlationMasks = {}) = 0;
|
||||||
virtual void beginRenderPass(PRenderPass renderPass) = 0;
|
virtual void beginRenderPass(PRenderPass renderPass) = 0;
|
||||||
virtual void endRenderPass() = 0;
|
virtual void endRenderPass() = 0;
|
||||||
virtual void waitDeviceIdle() = 0;
|
virtual void waitDeviceIdle() = 0;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "RayTracing.h"
|
#include "RayTracing.h"
|
||||||
#include "RayTracing.h"
|
|
||||||
|
|
||||||
using namespace Seele::Gfx;
|
using namespace Seele::Gfx;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Resources.h"
|
#include "Resources.h"
|
||||||
|
#include "Graphics/Descriptor.h"
|
||||||
|
|
||||||
namespace Seele {
|
namespace Seele {
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|||||||
@@ -407,7 +407,7 @@ void BasePass::publishOutputs() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
depthAttachment =
|
depthAttachment =
|
||||||
Gfx::RenderTargetAttachment(basePassDepth, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
Gfx::RenderTargetAttachment(Gfx::PTexture2D(basePassDepth), Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
||||||
Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
|
Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
|
||||||
|
|
||||||
msDepthAttachment =
|
msDepthAttachment =
|
||||||
@@ -472,7 +472,7 @@ void BasePass::createRenderPass() {
|
|||||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
renderPass = graphics->createRenderPass(std::move(layout), std::move(dependency), viewport, "BasePass");
|
renderPass = graphics->createRenderPass(std::move(layout), std::move(dependency), viewport->getRenderArea(), "BasePass");
|
||||||
oLightIndexList = resources->requestBuffer("LIGHTCULLING_OLIGHTLIST");
|
oLightIndexList = resources->requestBuffer("LIGHTCULLING_OLIGHTLIST");
|
||||||
tLightIndexList = resources->requestBuffer("LIGHTCULLING_TLIGHTLIST");
|
tLightIndexList = resources->requestBuffer("LIGHTCULLING_TLIGHTLIST");
|
||||||
oLightGrid = resources->requestTexture("LIGHTCULLING_OLIGHTGRID");
|
oLightGrid = resources->requestTexture("LIGHTCULLING_OLIGHTGRID");
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "CachedDepthPass.h"
|
#include "CachedDepthPass.h"
|
||||||
#include "Graphics/Shader.h"
|
#include "Graphics/Shader.h"
|
||||||
|
#include "Graphics/Pipeline.h"
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
@@ -202,5 +203,5 @@ void CachedDepthPass::createRenderPass() {
|
|||||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
renderPass = graphics->createRenderPass(std::move(layout), std::move(dependency), viewport, "CachedDepthPass");
|
renderPass = graphics->createRenderPass(std::move(layout), std::move(dependency), viewport->getRenderArea(), "CachedDepthPass");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -306,5 +306,5 @@ void DepthCullingPass::createRenderPass() {
|
|||||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
renderPass = graphics->createRenderPass(std::move(layout), std::move(dependency), viewport, "DepthCullingPass");
|
renderPass = graphics->createRenderPass(std::move(layout), std::move(dependency), viewport->getRenderArea(), "DepthCullingPass");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "Component/Camera.h"
|
#include "Component/Camera.h"
|
||||||
#include "Graphics/Command.h"
|
#include "Graphics/Command.h"
|
||||||
#include "Graphics/Graphics.h"
|
#include "Graphics/Graphics.h"
|
||||||
|
#include "Graphics/Pipeline.h"
|
||||||
#include "Math/Vector.h"
|
#include "Math/Vector.h"
|
||||||
#include "RenderGraph.h"
|
#include "RenderGraph.h"
|
||||||
#include "Scene/Scene.h"
|
#include "Scene/Scene.h"
|
||||||
@@ -48,8 +49,8 @@ void LightCullingPass::render() {
|
|||||||
cullingDescriptorSet->updateBuffer(TLIGHTINDEXCOUNTER_NAME, 0, tLightIndexCounter);
|
cullingDescriptorSet->updateBuffer(TLIGHTINDEXCOUNTER_NAME, 0, tLightIndexCounter);
|
||||||
cullingDescriptorSet->updateBuffer(OLIGHTINDEXLIST_NAME, 0, oLightIndexList);
|
cullingDescriptorSet->updateBuffer(OLIGHTINDEXLIST_NAME, 0, oLightIndexList);
|
||||||
cullingDescriptorSet->updateBuffer(TLIGHTINDEXLIST_NAME, 0, tLightIndexList);
|
cullingDescriptorSet->updateBuffer(TLIGHTINDEXLIST_NAME, 0, tLightIndexList);
|
||||||
cullingDescriptorSet->updateTexture(OLIGHTGRID_NAME, 0, oLightGrid);
|
cullingDescriptorSet->updateTexture(OLIGHTGRID_NAME, 0, Gfx::PTexture2D(oLightGrid));
|
||||||
cullingDescriptorSet->updateTexture(TLIGHTGRID_NAME, 0, tLightGrid);
|
cullingDescriptorSet->updateTexture(TLIGHTGRID_NAME, 0, Gfx::PTexture2D(tLightGrid));
|
||||||
cullingDescriptorSet->writeChanges();
|
cullingDescriptorSet->writeChanges();
|
||||||
Gfx::OComputeCommand computeCommand = graphics->createComputeCommand("CullingCommand");
|
Gfx::OComputeCommand computeCommand = graphics->createComputeCommand("CullingCommand");
|
||||||
if (getGlobals().useLightCulling) {
|
if (getGlobals().useLightCulling) {
|
||||||
|
|||||||
@@ -151,8 +151,8 @@ void RayTracingPass::render() {
|
|||||||
});
|
});
|
||||||
Gfx::PDescriptorSet desc = paramsLayout->allocateDescriptorSet();
|
Gfx::PDescriptorSet desc = paramsLayout->allocateDescriptorSet();
|
||||||
desc->updateAccelerationStructure(TLAS_NAME, 0, tlas);
|
desc->updateAccelerationStructure(TLAS_NAME, 0, tlas);
|
||||||
desc->updateTexture(ACCUMULATOR_NAME, 0, radianceAccumulator);
|
desc->updateTexture(ACCUMULATOR_NAME, 0, Gfx::PTexture2D(radianceAccumulator));
|
||||||
desc->updateTexture(TEXTURE_NAME, 0, texture);
|
desc->updateTexture(TEXTURE_NAME, 0, Gfx::PTexture2D(texture));
|
||||||
desc->updateBuffer(INDEXBUFFER_NAME, 0, StaticMeshVertexData::getInstance()->getIndexBuffer());
|
desc->updateBuffer(INDEXBUFFER_NAME, 0, StaticMeshVertexData::getInstance()->getIndexBuffer());
|
||||||
desc->updateTexture(SKYBOX_NAME, 0, skyBox);
|
desc->updateTexture(SKYBOX_NAME, 0, skyBox);
|
||||||
desc->updateSampler(SKYSAMPLER_NAME, 0, skyBoxSampler);
|
desc->updateSampler(SKYSAMPLER_NAME, 0, skyBoxSampler);
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ void ToneMappingPass::createRenderPass() {
|
|||||||
.dstAccess = Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
.dstAccess = Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
renderPass = graphics->createRenderPass(targetLayout, dependency, viewport, "ToneMappingPass");
|
renderPass = graphics->createRenderPass(targetLayout, dependency, viewport->getRenderArea(), "ToneMappingPass");
|
||||||
pipeline = graphics->createGraphicsPipeline(Gfx::LegacyPipelineCreateInfo{
|
pipeline = graphics->createGraphicsPipeline(Gfx::LegacyPipelineCreateInfo{
|
||||||
.vertexShader = vert,
|
.vertexShader = vert,
|
||||||
.fragmentShader = frag,
|
.fragmentShader = frag,
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ void UIPass::createRenderPass() {
|
|||||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
renderPass = graphics->createRenderPass(std::move(layout), dependency, viewport, "TextPass");
|
renderPass = graphics->createRenderPass(std::move(layout), dependency, viewport->getRenderArea(), "TextPass");
|
||||||
|
|
||||||
graphics->beginShaderCompilation(ShaderCompilationInfo{
|
graphics->beginShaderCompilation(ShaderCompilationInfo{
|
||||||
.name = "TextVertex",
|
.name = "TextVertex",
|
||||||
|
|||||||
@@ -9,6 +9,12 @@ RenderTargetAttachment::RenderTargetAttachment(PTexture2D texture, SeImageLayout
|
|||||||
: clear(), componentFlags(0), texture(texture), initialLayout(initialLayout), finalLayout(finalLayout), loadOp(loadOp),
|
: clear(), componentFlags(0), texture(texture), initialLayout(initialLayout), finalLayout(finalLayout), loadOp(loadOp),
|
||||||
storeOp(storeOp), stencilLoadOp(stencilLoadOp), stencilStoreOp(stencilStoreOp) {}
|
storeOp(storeOp), stencilLoadOp(stencilLoadOp), stencilStoreOp(stencilStoreOp) {}
|
||||||
|
|
||||||
|
RenderTargetAttachment::RenderTargetAttachment(PTextureCube texture, SeImageLayout initialLayout, SeImageLayout finalLayout,
|
||||||
|
SeAttachmentLoadOp loadOp, SeAttachmentStoreOp storeOp, SeAttachmentLoadOp stencilLoadOp,
|
||||||
|
SeAttachmentStoreOp stencilStoreOp)
|
||||||
|
: clear(), componentFlags(0), texture(texture), initialLayout(initialLayout), finalLayout(finalLayout), loadOp(loadOp),
|
||||||
|
storeOp(storeOp), stencilLoadOp(stencilLoadOp), stencilStoreOp(stencilStoreOp) {}
|
||||||
|
|
||||||
RenderTargetAttachment::RenderTargetAttachment(PViewport viewport, SeImageLayout initialLayout, SeImageLayout finalLayout,
|
RenderTargetAttachment::RenderTargetAttachment(PViewport viewport, SeImageLayout initialLayout, SeImageLayout finalLayout,
|
||||||
SeAttachmentLoadOp loadOp, SeAttachmentStoreOp storeOp, SeAttachmentLoadOp stencilLoadOp,
|
SeAttachmentLoadOp loadOp, SeAttachmentStoreOp storeOp, SeAttachmentLoadOp stencilLoadOp,
|
||||||
SeAttachmentStoreOp stencilStoreOp)
|
SeAttachmentStoreOp stencilStoreOp)
|
||||||
|
|||||||
@@ -14,16 +14,21 @@ class RenderTargetAttachment {
|
|||||||
SeAttachmentStoreOp storeOp = SE_ATTACHMENT_STORE_OP_STORE,
|
SeAttachmentStoreOp storeOp = SE_ATTACHMENT_STORE_OP_STORE,
|
||||||
SeAttachmentLoadOp stencilLoadOp = SE_ATTACHMENT_LOAD_OP_DONT_CARE,
|
SeAttachmentLoadOp stencilLoadOp = SE_ATTACHMENT_LOAD_OP_DONT_CARE,
|
||||||
SeAttachmentStoreOp stencilStoreOp = SE_ATTACHMENT_STORE_OP_DONT_CARE);
|
SeAttachmentStoreOp stencilStoreOp = SE_ATTACHMENT_STORE_OP_DONT_CARE);
|
||||||
|
RenderTargetAttachment(PTextureCube texture, SeImageLayout initialLayout, SeImageLayout finalLayout,
|
||||||
|
SeAttachmentLoadOp loadOp = SE_ATTACHMENT_LOAD_OP_LOAD,
|
||||||
|
SeAttachmentStoreOp storeOp = SE_ATTACHMENT_STORE_OP_STORE,
|
||||||
|
SeAttachmentLoadOp stencilLoadOp = SE_ATTACHMENT_LOAD_OP_DONT_CARE,
|
||||||
|
SeAttachmentStoreOp stencilStoreOp = SE_ATTACHMENT_STORE_OP_DONT_CARE);
|
||||||
RenderTargetAttachment(PViewport viewport, SeImageLayout initialLayout, SeImageLayout finalLayout,
|
RenderTargetAttachment(PViewport viewport, SeImageLayout initialLayout, SeImageLayout finalLayout,
|
||||||
SeAttachmentLoadOp loadOp = SE_ATTACHMENT_LOAD_OP_LOAD,
|
SeAttachmentLoadOp loadOp = SE_ATTACHMENT_LOAD_OP_LOAD,
|
||||||
SeAttachmentStoreOp storeOp = SE_ATTACHMENT_STORE_OP_STORE,
|
SeAttachmentStoreOp storeOp = SE_ATTACHMENT_STORE_OP_STORE,
|
||||||
SeAttachmentLoadOp stencilLoadOp = SE_ATTACHMENT_LOAD_OP_DONT_CARE,
|
SeAttachmentLoadOp stencilLoadOp = SE_ATTACHMENT_LOAD_OP_DONT_CARE,
|
||||||
SeAttachmentStoreOp stencilStoreOp = SE_ATTACHMENT_STORE_OP_DONT_CARE);
|
SeAttachmentStoreOp stencilStoreOp = SE_ATTACHMENT_STORE_OP_DONT_CARE);
|
||||||
~RenderTargetAttachment();
|
~RenderTargetAttachment();
|
||||||
PTexture2D getTexture() const {
|
void setTexture(PTexture _texture) { texture = _texture; }
|
||||||
|
PTexture getTexture() const {
|
||||||
if (viewport != nullptr) {
|
if (viewport != nullptr) {
|
||||||
return viewport->getOwner()->getBackBuffer();
|
return PTexture(viewport->getOwner()->getBackBuffer());
|
||||||
}
|
}
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
@@ -68,7 +73,7 @@ class RenderTargetAttachment {
|
|||||||
SeColorComponentFlags componentFlags = 0;
|
SeColorComponentFlags componentFlags = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PTexture2D texture = nullptr;
|
PTexture texture = nullptr;
|
||||||
PViewport viewport = nullptr;
|
PViewport viewport = nullptr;
|
||||||
SeImageLayout initialLayout = SE_IMAGE_LAYOUT_UNDEFINED;
|
SeImageLayout initialLayout = SE_IMAGE_LAYOUT_UNDEFINED;
|
||||||
SeImageLayout finalLayout = SE_IMAGE_LAYOUT_UNDEFINED;
|
SeImageLayout finalLayout = SE_IMAGE_LAYOUT_UNDEFINED;
|
||||||
@@ -103,6 +108,7 @@ class RenderPass {
|
|||||||
RenderPass(RenderPass&&) = default;
|
RenderPass(RenderPass&&) = default;
|
||||||
RenderPass& operator=(RenderPass&&) = default;
|
RenderPass& operator=(RenderPass&&) = default;
|
||||||
const RenderTargetLayout& getLayout() const { return layout; }
|
const RenderTargetLayout& getLayout() const { return layout; }
|
||||||
|
void updateColorAttachment(uint32 index, Gfx::PTextureCube attachment) { layout.colorAttachments[index].setTexture(attachment); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RenderTargetLayout layout;
|
RenderTargetLayout layout;
|
||||||
|
|||||||
@@ -312,63 +312,7 @@ void DescriptorSet::updateSampler(const std::string& mappingName, uint32 index,
|
|||||||
boundResources[binding][index] = vulkanSampler->getHandle();
|
boundResources[binding][index] = vulkanSampler->getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorSet::updateTexture(const std::string& mappingName, uint32 index, Gfx::PTexture2D texture) {
|
void DescriptorSet::updateTexture(const std::string& mappingName, uint32 index, Gfx::PTexture texture) {
|
||||||
TextureBase* vulkanTexture = texture.cast<TextureBase>().getHandle();
|
|
||||||
const auto& map = owner->getLayout()->mappings[mappingName];
|
|
||||||
uint32 binding = map.binding;
|
|
||||||
if (boundResources[binding][index] == vulkanTexture->getHandle()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 = map.type,
|
|
||||||
.pImageInfo = &imageInfos.back(),
|
|
||||||
});
|
|
||||||
|
|
||||||
boundResources[binding][index] = vulkanTexture->getHandle();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DescriptorSet::updateTexture(const std::string& mappingName, uint32 index, Gfx::PTexture3D texture) {
|
|
||||||
TextureBase* vulkanTexture = texture.cast<TextureBase>().getHandle();
|
|
||||||
const auto& map = owner->getLayout()->mappings[mappingName];
|
|
||||||
uint32 binding = map.binding;
|
|
||||||
if (boundResources[binding][index] == vulkanTexture->getHandle()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 = map.type,
|
|
||||||
.pImageInfo = &imageInfos.back(),
|
|
||||||
});
|
|
||||||
|
|
||||||
boundResources[binding][index] = vulkanTexture->getHandle();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DescriptorSet::updateTexture(const std::string& mappingName, uint32 index, Gfx::PTextureCube texture) {
|
|
||||||
TextureBase* vulkanTexture = texture.cast<TextureBase>().getHandle();
|
TextureBase* vulkanTexture = texture.cast<TextureBase>().getHandle();
|
||||||
const auto& map = owner->getLayout()->mappings[mappingName];
|
const auto& map = owner->getLayout()->mappings[mappingName];
|
||||||
uint32 binding = map.binding;
|
uint32 binding = map.binding;
|
||||||
|
|||||||
@@ -64,9 +64,7 @@ class DescriptorSet : public Gfx::DescriptorSet, public CommandBoundResource {
|
|||||||
virtual void updateBuffer(const std::string& name, uint32 index, Gfx::PVertexBuffer indexBuffer) override;
|
virtual void updateBuffer(const std::string& name, uint32 index, Gfx::PVertexBuffer indexBuffer) override;
|
||||||
virtual void updateBuffer(const std::string& name, uint32 index, Gfx::PIndexBuffer indexBuffer) override;
|
virtual void updateBuffer(const std::string& name, uint32 index, Gfx::PIndexBuffer indexBuffer) override;
|
||||||
virtual void updateSampler(const std::string& name, uint32 index, Gfx::PSampler samplerState) override;
|
virtual void updateSampler(const std::string& name, uint32 index, Gfx::PSampler samplerState) override;
|
||||||
virtual void updateTexture(const std::string& name, uint32 index, Gfx::PTexture2D texture) override;
|
virtual void updateTexture(const std::string& name, uint32 index, Gfx::PTexture texture) override;
|
||||||
virtual void updateTexture(const std::string& name, uint32 index, Gfx::PTexture3D texture) override;
|
|
||||||
virtual void updateTexture(const std::string& name, uint32 index, Gfx::PTextureCube texture) override;
|
|
||||||
virtual void updateAccelerationStructure(const std::string& name, uint32 index, Gfx::PTopLevelAS as) override;
|
virtual void updateAccelerationStructure(const std::string& name, uint32 index, Gfx::PTopLevelAS as) override;
|
||||||
|
|
||||||
constexpr VkDescriptorSet getHandle() const { return setHandle; }
|
constexpr VkDescriptorSet getHandle() const { return setHandle; }
|
||||||
|
|||||||
@@ -17,35 +17,35 @@ Framebuffer::Framebuffer(PGraphics graphics, PRenderPass renderPass, Gfx::Render
|
|||||||
uint32 width = 0;
|
uint32 width = 0;
|
||||||
uint32 height = 0;
|
uint32 height = 0;
|
||||||
for (auto inputAttachment : layout.inputAttachments) {
|
for (auto inputAttachment : layout.inputAttachments) {
|
||||||
PTexture2D vkInputAttachment = inputAttachment.getTexture().cast<Texture2D>();
|
PTextureBase vkInputAttachment = inputAttachment.getTexture().cast<TextureBase>();
|
||||||
attachments.add(vkInputAttachment->getView());
|
attachments.add(vkInputAttachment->getView());
|
||||||
description.inputAttachments[description.numInputAttachments++] = vkInputAttachment->getView();
|
description.inputAttachments[description.numInputAttachments++] = vkInputAttachment->getView();
|
||||||
width = std::max(width, vkInputAttachment->getWidth());
|
width = std::max(width, vkInputAttachment->getWidth());
|
||||||
height = std::max(height, vkInputAttachment->getHeight());
|
height = std::max(height, vkInputAttachment->getHeight());
|
||||||
}
|
}
|
||||||
for (auto colorAttachment : layout.colorAttachments) {
|
for (auto colorAttachment : layout.colorAttachments) {
|
||||||
PTexture2D vkColorAttachment = colorAttachment.getTexture().cast<Texture2D>();
|
PTextureBase vkColorAttachment = colorAttachment.getTexture().cast<TextureBase>();
|
||||||
attachments.add(vkColorAttachment->getView());
|
attachments.add(vkColorAttachment->getView());
|
||||||
description.colorAttachments[description.numColorAttachments++] = vkColorAttachment->getView();
|
description.colorAttachments[description.numColorAttachments++] = vkColorAttachment->getView();
|
||||||
width = std::max(width, vkColorAttachment->getWidth());
|
width = std::max(width, vkColorAttachment->getWidth());
|
||||||
height = std::max(height, vkColorAttachment->getHeight());
|
height = std::max(height, vkColorAttachment->getHeight());
|
||||||
}
|
}
|
||||||
for (auto resolveAttachment : layout.resolveAttachments) {
|
for (auto resolveAttachment : layout.resolveAttachments) {
|
||||||
PTexture2D vkResolveAttachment = resolveAttachment.getTexture().cast<Texture2D>();
|
PTextureBase vkResolveAttachment = resolveAttachment.getTexture().cast<TextureBase>();
|
||||||
attachments.add(vkResolveAttachment->getView());
|
attachments.add(vkResolveAttachment->getView());
|
||||||
description.resolveAttachments[description.numResolveAttachments++] = vkResolveAttachment->getView();
|
description.resolveAttachments[description.numResolveAttachments++] = vkResolveAttachment->getView();
|
||||||
width = std::max(width, vkResolveAttachment->getWidth());
|
width = std::max(width, vkResolveAttachment->getWidth());
|
||||||
height = std::max(height, vkResolveAttachment->getHeight());
|
height = std::max(height, vkResolveAttachment->getHeight());
|
||||||
}
|
}
|
||||||
if (layout.depthAttachment.getTexture() != nullptr) {
|
if (layout.depthAttachment.getTexture() != nullptr) {
|
||||||
PTexture2D vkDepthAttachment = layout.depthAttachment.getTexture().cast<Texture2D>();
|
PTextureBase vkDepthAttachment = layout.depthAttachment.getTexture().cast<TextureBase>();
|
||||||
attachments.add(vkDepthAttachment->getView());
|
attachments.add(vkDepthAttachment->getView());
|
||||||
description.depthAttachment = vkDepthAttachment->getView();
|
description.depthAttachment = vkDepthAttachment->getView();
|
||||||
width = std::max(width, vkDepthAttachment->getWidth());
|
width = std::max(width, vkDepthAttachment->getWidth());
|
||||||
height = std::max(height, vkDepthAttachment->getHeight());
|
height = std::max(height, vkDepthAttachment->getHeight());
|
||||||
}
|
}
|
||||||
if (layout.depthResolveAttachment.getTexture() != nullptr) {
|
if (layout.depthResolveAttachment.getTexture() != nullptr) {
|
||||||
PTexture2D vkDepthAttachment = layout.depthResolveAttachment.getTexture().cast<Texture2D>();
|
PTextureBase vkDepthAttachment = layout.depthResolveAttachment.getTexture().cast<TextureBase>();
|
||||||
attachments.add(vkDepthAttachment->getView());
|
attachments.add(vkDepthAttachment->getView());
|
||||||
description.depthResolveAttachment = vkDepthAttachment->getView();
|
description.depthResolveAttachment = vkDepthAttachment->getView();
|
||||||
width = std::max(width, vkDepthAttachment->getWidth());
|
width = std::max(width, vkDepthAttachment->getWidth());
|
||||||
|
|||||||
@@ -172,8 +172,9 @@ Gfx::OViewport Graphics::createViewport(Gfx::PWindow owner, const ViewportCreate
|
|||||||
}
|
}
|
||||||
|
|
||||||
Gfx::ORenderPass Graphics::createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies,
|
Gfx::ORenderPass Graphics::createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies,
|
||||||
Gfx::PViewport renderArea, std::string name) {
|
URect renderArea, std::string name, Array<uint32> viewMasks,
|
||||||
return new RenderPass(this, std::move(layout), std::move(dependencies), renderArea, name);
|
Array<uint32> correlationMasks) {
|
||||||
|
return new RenderPass(this, std::move(layout), std::move(dependencies), renderArea, name, std::move(viewMasks), std::move(correlationMasks));
|
||||||
}
|
}
|
||||||
void Graphics::beginRenderPass(Gfx::PRenderPass renderPass) {
|
void Graphics::beginRenderPass(Gfx::PRenderPass renderPass) {
|
||||||
PRenderPass rp = renderPass.cast<RenderPass>();
|
PRenderPass rp = renderPass.cast<RenderPass>();
|
||||||
@@ -824,6 +825,7 @@ void Graphics::pickPhysicalDevice() {
|
|||||||
.pNext = &features12,
|
.pNext = &features12,
|
||||||
.storageBuffer16BitAccess = true,
|
.storageBuffer16BitAccess = true,
|
||||||
.uniformAndStorageBuffer16BitAccess = true,
|
.uniformAndStorageBuffer16BitAccess = true,
|
||||||
|
.multiview = true,
|
||||||
};
|
};
|
||||||
features = {
|
features = {
|
||||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2,
|
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2,
|
||||||
@@ -950,6 +952,7 @@ void Graphics::createDevice(GraphicsInitializer initializer) {
|
|||||||
initializer.deviceExtensions.add(VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME);
|
initializer.deviceExtensions.add(VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME);
|
||||||
initializer.deviceExtensions.add(VK_KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME);
|
initializer.deviceExtensions.add(VK_KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME);
|
||||||
}
|
}
|
||||||
|
initializer.deviceExtensions.add(VK_KHR_MULTIVIEW_EXTENSION_NAME);
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
initializer.deviceExtensions.add("VK_KHR_portability_subset");
|
initializer.deviceExtensions.add("VK_KHR_portability_subset");
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ class Graphics : public Gfx::Graphics {
|
|||||||
virtual Gfx::OViewport createViewport(Gfx::PWindow owner, const ViewportCreateInfo& createInfo) override;
|
virtual Gfx::OViewport createViewport(Gfx::PWindow owner, const ViewportCreateInfo& createInfo) override;
|
||||||
|
|
||||||
virtual Gfx::ORenderPass createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies,
|
virtual Gfx::ORenderPass createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies,
|
||||||
Gfx::PViewport renderArea, std::string name) override;
|
URect renderArea, std::string name, Array<uint32> viewMasks,
|
||||||
|
Array<uint32> correlationMasks) override;
|
||||||
virtual void beginRenderPass(Gfx::PRenderPass renderPass) override;
|
virtual void beginRenderPass(Gfx::PRenderPass renderPass) override;
|
||||||
virtual void endRenderPass() override;
|
virtual void endRenderPass() override;
|
||||||
virtual void waitDeviceIdle() override;
|
virtual void waitDeviceIdle() override;
|
||||||
|
|||||||
@@ -6,17 +6,16 @@
|
|||||||
#include "Resources.h"
|
#include "Resources.h"
|
||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
using namespace Seele::Vulkan;
|
using namespace Seele::Vulkan;
|
||||||
|
|
||||||
RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Array<Gfx::SubPassDependency> _dependencies,
|
RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Array<Gfx::SubPassDependency> _dependencies,
|
||||||
Gfx::PViewport viewport, std::string name)
|
URect viewport, std::string name, Array<uint32> viewMasks, Array<uint32> correlationMasks)
|
||||||
: Gfx::RenderPass(std::move(_layout), std::move(_dependencies)), graphics(graphics) {
|
: Gfx::RenderPass(std::move(_layout), std::move(_dependencies)), graphics(graphics) {
|
||||||
renderArea.extent.width = viewport->getWidth();
|
renderArea.extent.width = viewport.size.x;
|
||||||
renderArea.extent.height = viewport->getHeight();
|
renderArea.extent.height = viewport.size.y;
|
||||||
renderArea.offset.x = viewport->getOffsetX();
|
renderArea.offset.x = viewport.offset.x;
|
||||||
renderArea.offset.y = viewport->getOffsetY();
|
renderArea.offset.y = viewport.offset.y;
|
||||||
subpassContents = VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS;
|
subpassContents = VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS;
|
||||||
Array<VkAttachmentDescription2> attachments;
|
Array<VkAttachmentDescription2> attachments;
|
||||||
Array<VkAttachmentReference2> inputRefs;
|
Array<VkAttachmentReference2> inputRefs;
|
||||||
@@ -198,7 +197,18 @@ RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Arra
|
|||||||
.dependencyCount = (uint32)dep.size(),
|
.dependencyCount = (uint32)dep.size(),
|
||||||
.pDependencies = dep.data(),
|
.pDependencies = dep.data(),
|
||||||
};
|
};
|
||||||
|
VkRenderPassMultiviewCreateInfo multiViewInfo;
|
||||||
|
if (!viewMasks.empty()) {
|
||||||
|
multiViewInfo = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.subpassCount = 1,
|
||||||
|
.pViewMasks = viewMasks.data(),
|
||||||
|
.correlationMaskCount = (uint32)correlationMasks.size(),
|
||||||
|
.pCorrelationMasks = correlationMasks.data(),
|
||||||
|
};
|
||||||
|
info.pNext = &multiViewInfo;
|
||||||
|
}
|
||||||
VK_CHECK(vkCreateRenderPass2(graphics->getDevice(), &info, nullptr, &renderPass));
|
VK_CHECK(vkCreateRenderPass2(graphics->getDevice(), &info, nullptr, &renderPass));
|
||||||
VkDebugUtilsObjectNameInfoEXT nameInfo = {
|
VkDebugUtilsObjectNameInfoEXT nameInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT,
|
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT,
|
||||||
@@ -220,23 +230,23 @@ uint32 RenderPass::getFramebufferHash() {
|
|||||||
FramebufferDescription description;
|
FramebufferDescription description;
|
||||||
std::memset(&description, 0, sizeof(FramebufferDescription));
|
std::memset(&description, 0, sizeof(FramebufferDescription));
|
||||||
for (auto& inputAttachment : layout.inputAttachments) {
|
for (auto& inputAttachment : layout.inputAttachments) {
|
||||||
PTexture2D tex = inputAttachment.getTexture().cast<Texture2D>();
|
PTextureBase tex = inputAttachment.getTexture().cast<TextureBase>();
|
||||||
description.inputAttachments[description.numInputAttachments++] = tex->getView();
|
description.inputAttachments[description.numInputAttachments++] = tex->getView();
|
||||||
}
|
}
|
||||||
for (auto& colorAttachment : layout.colorAttachments) {
|
for (auto& colorAttachment : layout.colorAttachments) {
|
||||||
PTexture2D tex = colorAttachment.getTexture().cast<Texture2D>();
|
PTextureBase tex = colorAttachment.getTexture().cast<TextureBase>();
|
||||||
description.colorAttachments[description.numColorAttachments++] = tex->getView();
|
description.colorAttachments[description.numColorAttachments++] = tex->getView();
|
||||||
}
|
}
|
||||||
for (auto& resolveAttachment : layout.resolveAttachments) {
|
for (auto& resolveAttachment : layout.resolveAttachments) {
|
||||||
PTexture2D tex = resolveAttachment.getTexture().cast<Texture2D>();
|
PTextureBase tex = resolveAttachment.getTexture().cast<TextureBase>();
|
||||||
description.resolveAttachments[description.numResolveAttachments++] = tex->getView();
|
description.resolveAttachments[description.numResolveAttachments++] = tex->getView();
|
||||||
}
|
}
|
||||||
if (layout.depthAttachment.getTexture() != nullptr) {
|
if (layout.depthAttachment.getTexture() != nullptr) {
|
||||||
PTexture2D tex = layout.depthAttachment.getTexture().cast<Texture2D>();
|
PTextureBase tex = layout.depthAttachment.getTexture().cast<TextureBase>();
|
||||||
description.depthAttachment = tex->getView();
|
description.depthAttachment = tex->getView();
|
||||||
}
|
}
|
||||||
if (layout.depthResolveAttachment.getTexture() != nullptr) {
|
if (layout.depthResolveAttachment.getTexture() != nullptr) {
|
||||||
PTexture2D tex = layout.depthResolveAttachment.getTexture().cast<Texture2D>();
|
PTextureBase tex = layout.depthResolveAttachment.getTexture().cast<TextureBase>();
|
||||||
description.depthResolveAttachment = tex->getView();
|
description.depthResolveAttachment = tex->getView();
|
||||||
}
|
}
|
||||||
return CRC::Calculate(&description, sizeof(FramebufferDescription), CRC::CRC_32());
|
return CRC::Calculate(&description, sizeof(FramebufferDescription), CRC::CRC_32());
|
||||||
@@ -244,23 +254,23 @@ uint32 RenderPass::getFramebufferHash() {
|
|||||||
|
|
||||||
void RenderPass::endRenderPass() {
|
void RenderPass::endRenderPass() {
|
||||||
for (auto& inputAttachment : layout.inputAttachments) {
|
for (auto& inputAttachment : layout.inputAttachments) {
|
||||||
PTexture2D tex = inputAttachment.getTexture().cast<Texture2D>();
|
PTextureBase tex = inputAttachment.getTexture().cast<TextureBase>();
|
||||||
tex->setLayout(inputAttachment.getFinalLayout());
|
tex->setLayout(inputAttachment.getFinalLayout());
|
||||||
}
|
}
|
||||||
for (auto& colorAttachment : layout.colorAttachments) {
|
for (auto& colorAttachment : layout.colorAttachments) {
|
||||||
PTexture2D tex = colorAttachment.getTexture().cast<Texture2D>();
|
PTextureBase tex = colorAttachment.getTexture().cast<TextureBase>();
|
||||||
tex->setLayout(colorAttachment.getFinalLayout());
|
tex->setLayout(colorAttachment.getFinalLayout());
|
||||||
}
|
}
|
||||||
for (auto& resolveAttachment : layout.resolveAttachments) {
|
for (auto& resolveAttachment : layout.resolveAttachments) {
|
||||||
PTexture2D tex = resolveAttachment.getTexture().cast<Texture2D>();
|
PTextureBase tex = resolveAttachment.getTexture().cast<TextureBase>();
|
||||||
tex->setLayout(resolveAttachment.getFinalLayout());
|
tex->setLayout(resolveAttachment.getFinalLayout());
|
||||||
}
|
}
|
||||||
if (layout.depthAttachment.getTexture() != nullptr) {
|
if (layout.depthAttachment.getTexture() != nullptr) {
|
||||||
PTexture2D tex = layout.depthAttachment.getTexture().cast<Texture2D>();
|
PTextureBase tex = layout.depthAttachment.getTexture().cast<TextureBase>();
|
||||||
tex->setLayout(layout.depthAttachment.getFinalLayout());
|
tex->setLayout(layout.depthAttachment.getFinalLayout());
|
||||||
}
|
}
|
||||||
if (layout.depthResolveAttachment.getTexture() != nullptr) {
|
if (layout.depthResolveAttachment.getTexture() != nullptr) {
|
||||||
PTexture2D tex = layout.depthResolveAttachment.getTexture().cast<Texture2D>();
|
PTextureBase tex = layout.depthResolveAttachment.getTexture().cast<TextureBase>();
|
||||||
tex->setLayout(layout.depthResolveAttachment.getFinalLayout());
|
tex->setLayout(layout.depthResolveAttachment.getFinalLayout());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ namespace Seele {
|
|||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
class RenderPass : public Gfx::RenderPass {
|
class RenderPass : public Gfx::RenderPass {
|
||||||
public:
|
public:
|
||||||
RenderPass(PGraphics graphics, Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, Gfx::PViewport viewport, std::string name);
|
RenderPass(PGraphics graphics, Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, URect viewport,
|
||||||
|
std::string name, Array<uint32> viewMasks = {}, Array<uint32> correlationMasks = {});
|
||||||
virtual ~RenderPass();
|
virtual ~RenderPass();
|
||||||
uint32 getFramebufferHash();
|
uint32 getFramebufferHash();
|
||||||
void endRenderPass();
|
void endRenderPass();
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ VkImageAspectFlags getAspectFromFormat(Gfx::SeFormat format) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, const TextureCreateInfo& createInfo, VkImage existingImage)
|
TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, const TextureCreateInfo& createInfo, VkImage existingImage)
|
||||||
: CommandBoundResource(graphics, createInfo.name), image(existingImage), owner(createInfo.sourceData.owner), width(createInfo.width),
|
: CommandBoundResource(graphics, createInfo.name), image(existingImage), imageView(VK_NULL_HANDLE), allocation(nullptr),
|
||||||
height(createInfo.height), depth(createInfo.depth), arrayCount(createInfo.elements), layerCount(createInfo.layers), mipLevels(1),
|
owner(createInfo.sourceData.owner), width(createInfo.width), height(createInfo.height), depth(createInfo.depth),
|
||||||
samples(createInfo.samples), format(createInfo.format), usage(createInfo.usage),
|
arrayCount(createInfo.elements), layerCount(createInfo.layers), mipLevels(1), samples(createInfo.samples), format(createInfo.format),
|
||||||
layout(Gfx::SE_IMAGE_LAYOUT_UNDEFINED), aspect(getAspectFromFormat(createInfo.format)), ownsImage(false) {
|
usage(createInfo.usage), layout(Gfx::SE_IMAGE_LAYOUT_UNDEFINED), aspect(getAspectFromFormat(createInfo.format)), ownsImage(false) {
|
||||||
if (createInfo.useMip) {
|
if (createInfo.useMip) {
|
||||||
mipLevels = static_cast<uint32_t>(std::floor(std::log2(std::max(width, height)))) + 1;
|
mipLevels = static_cast<uint32_t>(std::floor(std::log2(std::max(width, height)))) + 1;
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,8 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, const
|
|||||||
.pObjectName = name.c_str(),
|
.pObjectName = name.c_str(),
|
||||||
};
|
};
|
||||||
vkSetDebugUtilsObjectNameEXT(graphics->getDevice(), &nameInfo);
|
vkSetDebugUtilsObjectNameEXT(graphics->getDevice(), &nameInfo);
|
||||||
ownsImage = true;const DataSource& sourceData = createInfo.sourceData;
|
ownsImage = true;
|
||||||
|
const DataSource& sourceData = createInfo.sourceData;
|
||||||
if (sourceData.size > 0) {
|
if (sourceData.size > 0) {
|
||||||
changeLayout(Gfx::SE_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_ACCESS_NONE, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
|
changeLayout(Gfx::SE_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_ACCESS_NONE, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
|
||||||
VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
|
VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
|
||||||
@@ -139,8 +140,8 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, const
|
|||||||
.imageExtent = {.width = width, .height = height, .depth = depth},
|
.imageExtent = {.width = width, .height = height, .depth = depth},
|
||||||
};
|
};
|
||||||
|
|
||||||
vkCmdCopyBufferToImage(commandPool->getCommands()->getHandle(), stagingAlloc->buffer, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
vkCmdCopyBufferToImage(commandPool->getCommands()->getHandle(), stagingAlloc->buffer, image,
|
||||||
1, ®ion);
|
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion);
|
||||||
|
|
||||||
commandPool->getCommands()->bindResource(PBufferAllocation(stagingAlloc));
|
commandPool->getCommands()->bindResource(PBufferAllocation(stagingAlloc));
|
||||||
generateMipmaps();
|
generateMipmaps();
|
||||||
@@ -385,7 +386,10 @@ TextureBase::TextureBase(PGraphics graphics, VkImageViewType viewType, const Tex
|
|||||||
: handle(new TextureHandle(graphics, viewType, createInfo, existingImage)), graphics(graphics),
|
: handle(new TextureHandle(graphics, viewType, createInfo, existingImage)), graphics(graphics),
|
||||||
initialOwner(createInfo.sourceData.owner) {}
|
initialOwner(createInfo.sourceData.owner) {}
|
||||||
|
|
||||||
TextureBase::~TextureBase() { graphics->getDestructionManager()->queueResourceForDestruction(std::move(handle)); }
|
TextureBase::~TextureBase() {
|
||||||
|
graphics->getDestructionManager()->queueResourceForDestruction(std::move(handle));
|
||||||
|
handle = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void TextureBase::pipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, VkAccessFlags dstAccess,
|
void TextureBase::pipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, VkAccessFlags dstAccess,
|
||||||
VkPipelineStageFlags dstStage) {
|
VkPipelineStageFlags dstStage) {
|
||||||
|
|||||||
@@ -6,15 +6,13 @@
|
|||||||
#include "Resources.h"
|
#include "Resources.h"
|
||||||
#include <vulkan/vulkan_core.h>
|
#include <vulkan/vulkan_core.h>
|
||||||
|
|
||||||
|
|
||||||
namespace Seele {
|
namespace Seele {
|
||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
class TextureHandle : public CommandBoundResource {
|
class TextureHandle : public CommandBoundResource {
|
||||||
public:
|
public:
|
||||||
TextureHandle(PGraphics graphics, VkImageViewType viewType, const TextureCreateInfo& createInfo, VkImage existingImage);
|
TextureHandle(PGraphics graphics, VkImageViewType viewType, const TextureCreateInfo& createInfo, VkImage existingImage);
|
||||||
virtual ~TextureHandle();
|
virtual ~TextureHandle();
|
||||||
void pipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, VkAccessFlags dstAccess,
|
void pipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, VkAccessFlags dstAccess, VkPipelineStageFlags dstStage);
|
||||||
VkPipelineStageFlags dstStage);
|
|
||||||
void transferOwnership(Gfx::QueueType newOwner);
|
void transferOwnership(Gfx::QueueType newOwner);
|
||||||
void changeLayout(Gfx::SeImageLayout newLayout, VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, VkAccessFlags dstAccess,
|
void changeLayout(Gfx::SeImageLayout newLayout, VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, VkAccessFlags dstAccess,
|
||||||
VkPipelineStageFlags dstStage);
|
VkPipelineStageFlags dstStage);
|
||||||
@@ -37,11 +35,15 @@ class TextureHandle : public CommandBoundResource {
|
|||||||
VkImageAspectFlags aspect;
|
VkImageAspectFlags aspect;
|
||||||
uint8 ownsImage;
|
uint8 ownsImage;
|
||||||
};
|
};
|
||||||
DECLARE_REF(TextureHandle)
|
DEFINE_REF(TextureHandle)
|
||||||
|
|
||||||
|
DECLARE_REF(TextureBase)
|
||||||
|
DECLARE_REF(Texture2D)
|
||||||
|
DECLARE_REF(Texture3D)
|
||||||
|
DECLARE_REF(TextureCube)
|
||||||
class TextureBase {
|
class TextureBase {
|
||||||
public:
|
public:
|
||||||
TextureBase(PGraphics graphics, VkImageViewType viewType, const TextureCreateInfo& createInfo,
|
TextureBase(PGraphics graphics, VkImageViewType viewType, const TextureCreateInfo& createInfo, VkImage existingImage = VK_NULL_HANDLE);
|
||||||
VkImage existingImage = VK_NULL_HANDLE);
|
|
||||||
virtual ~TextureBase();
|
virtual ~TextureBase();
|
||||||
uint32 getWidth() const { return handle->width; }
|
uint32 getWidth() const { return handle->width; }
|
||||||
uint32 getHeight() const { return handle->height; }
|
uint32 getHeight() const { return handle->height; }
|
||||||
@@ -58,13 +60,13 @@ class TextureBase {
|
|||||||
constexpr uint32 getMipLevels() const { return handle->mipLevels; }
|
constexpr uint32 getMipLevels() const { return handle->mipLevels; }
|
||||||
constexpr bool isDepthStencil() const { return handle->aspect & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT); }
|
constexpr bool isDepthStencil() const { return handle->aspect & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT); }
|
||||||
|
|
||||||
void pipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, VkAccessFlags dstAccess,
|
void pipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, VkAccessFlags dstAccess, VkPipelineStageFlags dstStage);
|
||||||
VkPipelineStageFlags dstStage);
|
|
||||||
void transferOwnership(Gfx::QueueType newOwner);
|
void transferOwnership(Gfx::QueueType newOwner);
|
||||||
void changeLayout(Gfx::SeImageLayout newLayout, VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, VkAccessFlags dstAccess,
|
void changeLayout(Gfx::SeImageLayout newLayout, VkAccessFlags srcAccess, VkPipelineStageFlags srcStage, VkAccessFlags dstAccess,
|
||||||
VkPipelineStageFlags dstStage);
|
VkPipelineStageFlags dstStage);
|
||||||
void download(uint32 mipLevel, uint32 arrayLayer, uint32 face, Array<uint8>& buffer);
|
void download(uint32 mipLevel, uint32 arrayLayer, uint32 face, Array<uint8>& buffer);
|
||||||
void generateMipmaps();
|
void generateMipmaps();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
OTextureHandle handle;
|
OTextureHandle handle;
|
||||||
// Updates via reference
|
// Updates via reference
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ Window::Window() {}
|
|||||||
Window::~Window() {}
|
Window::~Window() {}
|
||||||
|
|
||||||
Viewport::Viewport(PWindow owner, const ViewportCreateInfo& viewportInfo)
|
Viewport::Viewport(PWindow owner, const ViewportCreateInfo& viewportInfo)
|
||||||
: sizeX(std::min(owner->getFramebufferWidth(), viewportInfo.dimensions.size.x)),
|
: sizeX(viewportInfo.dimensions.size.x), sizeY(viewportInfo.dimensions.size.y), offsetX(viewportInfo.dimensions.offset.x),
|
||||||
sizeY(std::min(owner->getFramebufferHeight(), viewportInfo.dimensions.size.y)), offsetX(viewportInfo.dimensions.offset.x),
|
|
||||||
offsetY(viewportInfo.dimensions.offset.y), fieldOfView(viewportInfo.fieldOfView), owner(owner) {}
|
offsetY(viewportInfo.dimensions.offset.y), fieldOfView(viewportInfo.fieldOfView), owner(owner) {}
|
||||||
|
|
||||||
Viewport::~Viewport() {}
|
Viewport::~Viewport() {}
|
||||||
|
|||||||
@@ -53,6 +53,12 @@ class Viewport {
|
|||||||
constexpr float getContentScaleX() const { return owner->getContentScaleX(); }
|
constexpr float getContentScaleX() const { return owner->getContentScaleX(); }
|
||||||
constexpr float getContentScaleY() const { return owner->getContentScaleY(); }
|
constexpr float getContentScaleY() const { return owner->getContentScaleY(); }
|
||||||
Matrix4 getProjectionMatrix() const;
|
Matrix4 getProjectionMatrix() const;
|
||||||
|
URect getRenderArea() const {
|
||||||
|
return URect{
|
||||||
|
.size = {sizeX, sizeY},
|
||||||
|
.offset = {offsetX, offsetY},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint32 sizeX;
|
uint32 sizeX;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "ThreadPool.h"
|
#include "ThreadPool.h"
|
||||||
#include "MinimalEngine.h"
|
#include "MinimalEngine.h"
|
||||||
|
#include "Graphics/Texture.h"
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
@@ -7,6 +8,8 @@ Globals globals;
|
|||||||
|
|
||||||
Globals& Seele::getGlobals() { return globals; }
|
Globals& Seele::getGlobals() { return globals; }
|
||||||
|
|
||||||
|
void test(Gfx::PTexture base) { (void)base; }
|
||||||
|
|
||||||
ThreadPool::ThreadPool(uint32 numWorkers) {
|
ThreadPool::ThreadPool(uint32 numWorkers) {
|
||||||
for (uint32 i = 0; i < numWorkers; ++i) {
|
for (uint32 i = 0; i < numWorkers; ++i) {
|
||||||
workers.add(std::thread(&ThreadPool::work, this));
|
workers.add(std::thread(&ThreadPool::work, this));
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#include "EngineTest.h"
|
||||||
|
|
||||||
|
struct Foo {};
|
||||||
|
|
||||||
|
struct Derivate : public Foo {};
|
||||||
|
|
||||||
|
TEST(RefPtr, ImplicitUpcast) {
|
||||||
|
OwningPtr<Derivate> owner = new Derivate();
|
||||||
|
RefPtr<Derivate> der = owner;
|
||||||
|
RefPtr<Foo> foo = der;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user