Multi swapchain support (#257)

* multi swapchain draft

* uwp fix

* swapchain resize handling

* swapchain buffercount

* vsync toggle

* tests fix

* update

* everything removed from graphicsdevice regarding global screen params, engine refactor

* added GetSwapChainTexture() function to graphics device; screenshot() now requires swapChain

* linux fix: vulkan device needs window handle for instance creation

* refactor

* removed unused includes

* shader refactor and lensflare fix

* swapchain clearcolor and other refactors

* vulkan: no vector allocation in submit

* tests fix

* refactors

* lens flare canvas size fix

* gui refactor for canvas support

* refactors

* removed global canvas state

* msaa fix

* fixes

* refactor to minimize interface changes

* gui changes

* checkbox fix

* gui fixes

* fixes

* input system will accept window handle

* editor fixes

* refactor and removed resolution related system events

* small editor update

* refactor: renderpath inherits from canvas

* fixed tests duh

* image refactor

* image fix

* removed every using namespace std

* pushconstant fix

* editor: object picking only when necessary

* removed include

* dx12: copy fence waiting performed on CPU

* dx12 copyallocator update

* vulkan: copy allocator with timeline semaphores

* missing include

* dx12 copy allocator update

* refactor

* editor update

* vulkan copy allocator fix

* dx12 update

* vulkan, dx12 fixes

* version bump

* vsync event helper

* documentation update

* updated vulkan, dx12, dxc
This commit is contained in:
Turánszki János
2021-04-22 10:36:22 +01:00
committed by GitHub
parent 762e194a85
commit f1ced24f05
141 changed files with 75281 additions and 50418 deletions
+25 -14
View File
@@ -10,7 +10,6 @@
#include <atomic>
using namespace std;
using namespace wiGraphics;
namespace wiImage
@@ -21,8 +20,8 @@ namespace wiImage
IMAGE_SHADER_STANDARD,
IMAGE_SHADER_SEPARATENORMALMAP,
IMAGE_SHADER_MASKED,
IMAGE_SHADER_BACKGROUNDBLUR,
IMAGE_SHADER_BACKGROUNDBLUR_MASKED,
IMAGE_SHADER_BACKGROUND,
IMAGE_SHADER_BACKGROUND_MASKED,
IMAGE_SHADER_FULLSCREEN,
IMAGE_SHADER_COUNT
};
@@ -35,13 +34,19 @@ namespace wiImage
RasterizerState rasterizerState;
DepthStencilState depthStencilStates[STENCILMODE_COUNT][STENCILREFMODE_COUNT];
PipelineState imagePSO[IMAGE_SHADER_COUNT][BLENDMODE_COUNT][STENCILMODE_COUNT][STENCILREFMODE_COUNT];
Texture backgroundBlurTextures[COMMANDLIST_COUNT];
Texture backgroundTextures[COMMANDLIST_COUNT];
wiCanvas canvases[COMMANDLIST_COUNT];
std::atomic_bool initialized{ false };
void SetBackgroundBlurTexture(const Texture& texture, CommandList cmd)
void SetBackground(const Texture& texture, CommandList cmd)
{
backgroundBlurTextures[cmd] = texture;
backgroundTextures[cmd] = texture;
}
void SetCanvas(const wiCanvas& canvas, wiGraphics::CommandList cmd)
{
canvases[cmd] = canvas;
}
void Draw(const Texture* texture, const wiImageParams& params, CommandList cmd)
@@ -96,7 +101,7 @@ namespace wiImage
PushConstantsImage push;
push.texture_base_index = device->GetDescriptorIndex(texture, SRV);
push.texture_mask_index = device->GetDescriptorIndex(params.maskMap, SRV);
push.texture_background_index = device->GetDescriptorIndex(&backgroundBlurTextures[cmd], SRV);
push.texture_background_index = device->GetDescriptorIndex(&backgroundTextures[cmd], SRV);
push.sampler_index = device->GetDescriptorIndex(sampler);
device->PushConstants(&push, sizeof(push), cmd);
}
@@ -104,7 +109,7 @@ namespace wiImage
{
device->BindResource(PS, texture, TEXSLOT_IMAGE_BASE, cmd);
device->BindResource(PS, params.maskMap, TEXSLOT_IMAGE_MASK, cmd);
device->BindResource(PS, &backgroundBlurTextures[cmd], TEXSLOT_IMAGE_BACKGROUND, cmd);
device->BindResource(PS, &backgroundTextures[cmd], TEXSLOT_IMAGE_BACKGROUND, cmd);
device->BindSampler(PS, sampler, SSLOT_ONDEMAND0, cmd);
}
@@ -143,7 +148,13 @@ namespace wiImage
}
else
{
M = M * device->GetScreenProjection();
const wiCanvas& canvas = canvases[cmd];
// Asserts will check that a proper canvas was set for this cmd with wiImage::SetCanvas()
// The canvas must be set to have dpi aware rendering
assert(canvas.width > 0);
assert(canvas.height > 0);
assert(canvas.dpi > 0);
M = M * canvas.GetProjection();
}
for (int i = 0; i < 4; ++i)
@@ -197,7 +208,7 @@ namespace wiImage
IMAGE_SHADER targetShader;
const bool NormalmapSeparate = params.isExtractNormalMapEnabled();
const bool Mask = params.maskMap != nullptr;
const bool background_blur = params.isBackgroundBlurEnabled();
const bool background_blur = params.isBackgroundEnabled();
if (NormalmapSeparate)
{
targetShader = IMAGE_SHADER_SEPARATENORMALMAP;
@@ -208,7 +219,7 @@ namespace wiImage
{
if (background_blur)
{
targetShader = IMAGE_SHADER_BACKGROUNDBLUR_MASKED;
targetShader = IMAGE_SHADER_BACKGROUND_MASKED;
}
else
{
@@ -219,7 +230,7 @@ namespace wiImage
{
if (background_blur)
{
targetShader = IMAGE_SHADER_BACKGROUNDBLUR;
targetShader = IMAGE_SHADER_BACKGROUND;
}
else
{
@@ -249,8 +260,8 @@ namespace wiImage
wiRenderer::LoadShader(PS, imagePS[IMAGE_SHADER_STANDARD], "imagePS.cso");
wiRenderer::LoadShader(PS, imagePS[IMAGE_SHADER_SEPARATENORMALMAP], "imagePS_separatenormalmap.cso");
wiRenderer::LoadShader(PS, imagePS[IMAGE_SHADER_MASKED], "imagePS_masked.cso");
wiRenderer::LoadShader(PS, imagePS[IMAGE_SHADER_BACKGROUNDBLUR], "imagePS_backgroundblur.cso");
wiRenderer::LoadShader(PS, imagePS[IMAGE_SHADER_BACKGROUNDBLUR_MASKED], "imagePS_backgroundblur_masked.cso");
wiRenderer::LoadShader(PS, imagePS[IMAGE_SHADER_BACKGROUND], "imagePS_backgroundblur.cso");
wiRenderer::LoadShader(PS, imagePS[IMAGE_SHADER_BACKGROUND_MASKED], "imagePS_backgroundblur_masked.cso");
wiRenderer::LoadShader(PS, imagePS[IMAGE_SHADER_FULLSCREEN], "screenPS.cso");