refactors, fixes, sdk version update
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
<ProjectGuid>{5FE97B9B-A445-4EEA-A42D-9DE60B891D48}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>Editor</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>Editor</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<ProjectGuid>{76AA3D37-3252-4785-9334-3FC6B8CC07DE}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>Template_Windows</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@
|
||||
<ProjectGuid>{3A9EA3D0-A795-46ED-A737-7164E90DC309}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>Tests</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>Tests</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
|
||||
@@ -143,7 +143,7 @@ void RenderPath2D::Compose()
|
||||
fx.enableFullScreen();
|
||||
fx.blendFlag = BLENDMODE_PREMULTIPLIED;
|
||||
|
||||
wiImage::Draw(rtFinal.GetTexture(), fx, GRAPHICSTHREAD_IMMEDIATE);
|
||||
wiImage::Draw(&rtFinal.GetTexture(), fx, GRAPHICSTHREAD_IMMEDIATE);
|
||||
|
||||
RenderPath::Compose();
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
void Render() override;
|
||||
void Compose() override;
|
||||
|
||||
wiGraphicsTypes::Texture2D* GetRenderResult() { return rtFinal.GetTexture(); }
|
||||
const wiGraphicsTypes::Texture2D& GetRenderResult() { return rtFinal.GetTexture(); }
|
||||
|
||||
void addSprite(wiSprite* sprite, const std::string& layer = DEFAULT_RENDERLAYER);
|
||||
void removeSprite(wiSprite* sprite);
|
||||
|
||||
@@ -232,7 +232,7 @@ void RenderPath3D::Compose()
|
||||
|
||||
void RenderPath3D::RenderFrameSetUp(GRAPHICSTHREAD threadID)
|
||||
{
|
||||
wiRenderer::GetDevice()->BindResource(CS, dtDepthCopy.GetTexture(), TEXSLOT_DEPTH, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(CS, &dtDepthCopy.GetTexture(), TEXSLOT_DEPTH, threadID);
|
||||
wiRenderer::UpdateRenderData(threadID);
|
||||
|
||||
ViewPort viewPort;
|
||||
@@ -328,7 +328,7 @@ void RenderPath3D::RenderSecondaryScene(wiRenderTarget& mainRT, wiRenderTarget&
|
||||
wiRenderer::GetDevice()->TransitionBarrier(dsv, ARRAYSIZE(dsv), RESOURCE_STATE_DEPTH_READ, RESOURCE_STATE_DEPTH_WRITE, threadID);
|
||||
|
||||
fx.process.setDepthBufferDownsampling();
|
||||
wiImage::Draw(dtDepthCopy.GetTextureResolvedMSAA(threadID), fx, threadID);
|
||||
wiImage::Draw(&dtDepthCopy.GetTextureResolvedMSAA(threadID), fx, threadID);
|
||||
fx.process.clear();
|
||||
}
|
||||
wiRenderer::GetDevice()->EventEnd(threadID);
|
||||
@@ -357,7 +357,7 @@ void RenderPath3D::RenderSecondaryScene(wiRenderTarget& mainRT, wiRenderTarget&
|
||||
{
|
||||
wiRenderer::GetDevice()->EventBegin("Light Shafts", threadID);
|
||||
wiRenderer::GetDevice()->UnbindResources(TEXSLOT_ONDEMAND0, TEXSLOT_ONDEMAND_COUNT, threadID);
|
||||
rtSun[0].SetAndClear(threadID, mainRT.depth); {
|
||||
rtSun[0].SetAndClear(threadID, mainRT.depth.get()); {
|
||||
wiRenderer::DrawSun(threadID);
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ void RenderPath3D::RenderSecondaryScene(wiRenderTarget& mainRT, wiRenderTarget&
|
||||
XMFLOAT2 sun;
|
||||
XMStoreFloat2(&sun, sunPos);
|
||||
fxs.process.setLightShaftCenter(sun);
|
||||
wiImage::Draw(rtSun[0].GetTextureResolvedMSAA(threadID), fxs, threadID);
|
||||
wiImage::Draw(&rtSun[0].GetTextureResolvedMSAA(threadID), fxs, threadID);
|
||||
}
|
||||
}
|
||||
wiRenderer::GetDevice()->EventEnd(threadID);
|
||||
@@ -399,7 +399,7 @@ void RenderPath3D::RenderSecondaryScene(wiRenderTarget& mainRT, wiRenderTarget&
|
||||
fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
fx.quality = QUALITY_NEAREST;
|
||||
fx.enableFullScreen();
|
||||
wiImage::Draw(shadedSceneRT.GetTextureResolvedMSAA(threadID), fx, threadID);
|
||||
wiImage::Draw(&shadedSceneRT.GetTextureResolvedMSAA(threadID), fx, threadID);
|
||||
wiRenderer::GetDevice()->EventEnd(threadID);
|
||||
}
|
||||
|
||||
@@ -407,33 +407,34 @@ void RenderPath3D::RenderSecondaryScene(wiRenderTarget& mainRT, wiRenderTarget&
|
||||
wiRenderer::GetDevice()->UnbindResources(TEXSLOT_ONDEMAND0, TEXSLOT_ONDEMAND_COUNT, threadID);
|
||||
if (wiRenderer::GetAdvancedRefractionsEnabled())
|
||||
{
|
||||
wiRenderer::GenerateMipChain(rtSceneCopy.GetTexture(), wiRenderer::MIPGENFILTER_GAUSSIAN, threadID);
|
||||
wiRenderer::GenerateMipChain(&rtSceneCopy.GetTexture(), wiRenderer::MIPGENFILTER_GAUSSIAN, threadID);
|
||||
}
|
||||
shadedSceneRT.Set(threadID, mainRT.depth, false, 0);{
|
||||
shadedSceneRT.Set(threadID, mainRT.depth.get(), false, 0);{
|
||||
RenderTransparentScene(rtSceneCopy, threadID);
|
||||
|
||||
wiRenderer::DrawLightVisualizers(wiRenderer::GetCamera(), threadID);
|
||||
|
||||
fx.enableFullScreen();
|
||||
|
||||
if (getEmittedParticlesEnabled()) {
|
||||
if (getEmittedParticlesEnabled())
|
||||
{
|
||||
wiRenderer::GetDevice()->EventBegin("Contribute Emitters", threadID);
|
||||
fx.blendFlag = BLENDMODE_PREMULTIPLIED;
|
||||
wiImage::Draw(rtParticle.GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtParticle.GetTexture(), fx, threadID);
|
||||
wiRenderer::GetDevice()->EventEnd(threadID);
|
||||
}
|
||||
|
||||
if (getVolumeLightsEnabled())
|
||||
{
|
||||
wiRenderer::GetDevice()->EventBegin("Contribute Volumetric Lights", threadID);
|
||||
wiImage::Draw(rtVolumetricLights.GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtVolumetricLights.GetTexture(), fx, threadID);
|
||||
wiRenderer::GetDevice()->EventEnd(threadID);
|
||||
}
|
||||
|
||||
if (getLightShaftsEnabled()) {
|
||||
wiRenderer::GetDevice()->EventBegin("Contribute LightShafts", threadID);
|
||||
fx.blendFlag = BLENDMODE_ADDITIVE;
|
||||
wiImage::Draw(rtSun.back().GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtSun.back().GetTexture(), fx, threadID);
|
||||
wiRenderer::GetDevice()->EventEnd(threadID);
|
||||
}
|
||||
|
||||
@@ -458,9 +459,9 @@ void RenderPath3D::RenderTransparentScene(wiRenderTarget& refractionRT, GRAPHICS
|
||||
{
|
||||
wiProfiler::BeginRange("Transparent Scene", wiProfiler::DOMAIN_GPU, threadID);
|
||||
|
||||
wiRenderer::GetDevice()->BindResource(PS, getReflectionsEnabled() ? rtReflection.GetTexture() : wiTextureHelper::getTransparent(), TEXSLOT_RENDERABLECOMPONENT_REFLECTION, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, refractionRT.GetTexture(), TEXSLOT_RENDERABLECOMPONENT_REFRACTION, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, rtWaterRipple.GetTexture(), TEXSLOT_RENDERABLECOMPONENT_WATERRIPPLES, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, getReflectionsEnabled() ? &rtReflection.GetTexture() : wiTextureHelper::getTransparent(), TEXSLOT_RENDERABLECOMPONENT_REFLECTION, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, &refractionRT.GetTexture(), TEXSLOT_RENDERABLECOMPONENT_REFRACTION, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, &rtWaterRipple.GetTexture(), TEXSLOT_RENDERABLECOMPONENT_WATERRIPPLES, threadID);
|
||||
wiRenderer::DrawScene_Transparent(wiRenderer::GetCamera(), RENDERPASS_FORWARD, threadID, false, true, getLayerMask());
|
||||
|
||||
wiProfiler::EndRange(threadID); // Transparent Scene
|
||||
@@ -485,11 +486,11 @@ void RenderPath3D::RenderComposition(wiRenderTarget& shadedSceneRT, wiRenderTarg
|
||||
int current = wiRenderer::GetDevice()->GetFrameCount() % 2 == 0 ? 0 : 1;
|
||||
int history = 1 - current;
|
||||
rtTemporalAA[current].Set(threadID); {
|
||||
wiRenderer::BindGBufferTextures(mainRT.GetTextureResolvedMSAA(threadID, 0), mainRT.GetTextureResolvedMSAA(threadID, 1), nullptr, threadID);
|
||||
wiRenderer::BindGBufferTextures(&mainRT.GetTextureResolvedMSAA(threadID, 0), &mainRT.GetTextureResolvedMSAA(threadID, 1), nullptr, threadID);
|
||||
fx.disableFullScreen();
|
||||
fx.process.setTemporalAAResolve();
|
||||
fx.setMaskMap(rtTemporalAA[history].GetTexture());
|
||||
wiImage::Draw(shadedSceneRT.GetTextureResolvedMSAA(threadID), fx, threadID);
|
||||
fx.setMaskMap(&rtTemporalAA[history].GetTexture());
|
||||
wiImage::Draw(&shadedSceneRT.GetTextureResolvedMSAA(threadID), fx, threadID);
|
||||
fx.process.clear();
|
||||
}
|
||||
wiRenderer::GetDevice()->UnbindResources(TEXSLOT_GBUFFER0, 1, threadID);
|
||||
@@ -497,7 +498,7 @@ void RenderPath3D::RenderComposition(wiRenderTarget& shadedSceneRT, wiRenderTarg
|
||||
shadedSceneRT.Set(threadID, nullptr, false, 0); {
|
||||
fx.enableFullScreen();
|
||||
fx.quality = QUALITY_NEAREST;
|
||||
wiImage::Draw(rtTemporalAA[current].GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtTemporalAA[current].GetTexture(), fx, threadID);
|
||||
fx.disableFullScreen();
|
||||
}
|
||||
fx.disableHDR();
|
||||
@@ -517,12 +518,12 @@ void RenderPath3D::RenderComposition(wiRenderTarget& shadedSceneRT, wiRenderTarg
|
||||
rtBloom.Set(threadID); // separate bright parts
|
||||
{
|
||||
fx.process.setBloom(getBloomThreshold());
|
||||
wiImage::Draw(shadedSceneRT.GetTextureResolvedMSAA(threadID), fx, threadID);
|
||||
wiImage::Draw(&shadedSceneRT.GetTextureResolvedMSAA(threadID), fx, threadID);
|
||||
wiRenderer::GetDevice()->UnbindResources(TEXSLOT_ONDEMAND0, 1, threadID);
|
||||
}
|
||||
fx.process.clear();
|
||||
|
||||
wiRenderer::GenerateMipChain(rtBloom.GetTexture(), wiRenderer::MIPGENFILTER_GAUSSIAN, threadID);
|
||||
wiRenderer::GenerateMipChain(&rtBloom.GetTexture(), wiRenderer::MIPGENFILTER_GAUSSIAN, threadID);
|
||||
shadedSceneRT.Set(threadID, false, 0); { // add to the scene
|
||||
// not full screen effect, because we draw specific mip levels, so some setup is required
|
||||
XMFLOAT2 siz = fx.siz;
|
||||
@@ -531,11 +532,11 @@ void RenderPath3D::RenderComposition(wiRenderTarget& shadedSceneRT, wiRenderTarg
|
||||
//fx.quality = QUALITY_BICUBIC;
|
||||
fx.process.clear();
|
||||
fx.mipLevel = 1.5f;
|
||||
wiImage::Draw(rtBloom.GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtBloom.GetTexture(), fx, threadID);
|
||||
fx.mipLevel = 3.5f;
|
||||
wiImage::Draw(rtBloom.GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtBloom.GetTexture(), fx, threadID);
|
||||
fx.mipLevel = 5.5f;
|
||||
wiImage::Draw(rtBloom.GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtBloom.GetTexture(), fx, threadID);
|
||||
fx.quality = QUALITY_LINEAR;
|
||||
fx.siz = siz;
|
||||
}
|
||||
@@ -549,7 +550,7 @@ void RenderPath3D::RenderComposition(wiRenderTarget& shadedSceneRT, wiRenderTarg
|
||||
fx.process.setMotionBlur();
|
||||
fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
fx.disableFullScreen();
|
||||
wiImage::Draw(shadedSceneRT.GetTextureResolvedMSAA(threadID), fx, threadID);
|
||||
wiImage::Draw(&shadedSceneRT.GetTextureResolvedMSAA(threadID), fx, threadID);
|
||||
fx.process.clear();
|
||||
wiRenderer::GetDevice()->EventEnd(threadID);
|
||||
}
|
||||
@@ -560,10 +561,10 @@ void RenderPath3D::RenderComposition(wiRenderTarget& shadedSceneRT, wiRenderTarg
|
||||
fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
rtFinal[0].Set(threadID);
|
||||
fx.process.setToneMap(getExposure());
|
||||
fx.setDistortionMap(rtParticle.GetTexture());
|
||||
fx.setDistortionMap(&rtParticle.GetTexture());
|
||||
if (getEyeAdaptionEnabled())
|
||||
{
|
||||
fx.setMaskMap(wiRenderer::GetLuminance(shadedSceneRT.GetTextureResolvedMSAA(threadID), threadID));
|
||||
fx.setMaskMap(wiRenderer::GetLuminance(&shadedSceneRT.GetTextureResolvedMSAA(threadID), threadID));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -571,11 +572,11 @@ void RenderPath3D::RenderComposition(wiRenderTarget& shadedSceneRT, wiRenderTarg
|
||||
}
|
||||
if (getMotionBlurEnabled())
|
||||
{
|
||||
wiImage::Draw(rtMotionBlur.GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtMotionBlur.GetTexture(), fx, threadID);
|
||||
}
|
||||
else
|
||||
{
|
||||
wiImage::Draw(shadedSceneRT.GetTextureResolvedMSAA(threadID), fx, threadID);
|
||||
wiImage::Draw(&shadedSceneRT.GetTextureResolvedMSAA(threadID), fx, threadID);
|
||||
}
|
||||
fx.process.clear();
|
||||
wiRenderer::GetDevice()->EventEnd(threadID);
|
||||
@@ -587,7 +588,7 @@ void RenderPath3D::RenderComposition(wiRenderTarget& shadedSceneRT, wiRenderTarg
|
||||
rt1->Set(threadID);
|
||||
fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
fx.process.setSharpen(getSharpenFilterAmount());
|
||||
wiImage::Draw(rt0->GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rt0->GetTexture(), fx, threadID);
|
||||
fx.process.clear();
|
||||
wiRenderer::GetDevice()->UnbindResources(TEXSLOT_ONDEMAND0, 1, threadID);
|
||||
|
||||
@@ -601,19 +602,19 @@ void RenderPath3D::RenderComposition(wiRenderTarget& shadedSceneRT, wiRenderTarg
|
||||
fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
rtDof[0].Set(threadID);
|
||||
fx.process.setBlur(XMFLOAT2(getDepthOfFieldStrength(), 0));
|
||||
wiImage::Draw(rt0->GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rt0->GetTexture(), fx, threadID);
|
||||
|
||||
rtDof[1].Set(threadID);
|
||||
fx.process.setBlur(XMFLOAT2(0, getDepthOfFieldStrength()));
|
||||
wiImage::Draw(rtDof[0].GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtDof[0].GetTexture(), fx, threadID);
|
||||
fx.process.clear();
|
||||
|
||||
// depth of field compose pass
|
||||
rtDof[2].Set(threadID);
|
||||
fx.process.setDOF(getDepthOfFieldFocus());
|
||||
fx.setMaskMap(rtDof[1].GetTexture());
|
||||
fx.setMaskMap(&rtDof[1].GetTexture());
|
||||
//fx.setDepthMap(rtLinearDepth.shaderResource.back());
|
||||
wiImage::Draw(rt0->GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rt0->GetTexture(), fx, threadID);
|
||||
fx.setMaskMap(nullptr);
|
||||
//fx.setDepthMap(nullptr);
|
||||
fx.process.clear();
|
||||
@@ -632,9 +633,9 @@ void RenderPath3D::RenderComposition(wiRenderTarget& shadedSceneRT, wiRenderTarg
|
||||
fx.enableFullScreen();
|
||||
}
|
||||
if (getDepthOfFieldEnabled())
|
||||
wiImage::Draw(rtDof[2].GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtDof[2].GetTexture(), fx, threadID);
|
||||
else
|
||||
wiImage::Draw(rt0->GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rt0->GetTexture(), fx, threadID);
|
||||
fx.process.clear();
|
||||
wiRenderer::GetDevice()->EventEnd(threadID);
|
||||
|
||||
@@ -679,11 +680,11 @@ void RenderPath3D::RenderColorGradedComposition()
|
||||
|
||||
if (getSharpenFilterEnabled())
|
||||
{
|
||||
wiImage::Draw(rtFinal[0].GetTexture(), fx, GRAPHICSTHREAD_IMMEDIATE);
|
||||
wiImage::Draw(&rtFinal[0].GetTexture(), fx, GRAPHICSTHREAD_IMMEDIATE);
|
||||
}
|
||||
else
|
||||
{
|
||||
wiImage::Draw(rtFinal[1].GetTexture(), fx, GRAPHICSTHREAD_IMMEDIATE);
|
||||
wiImage::Draw(&rtFinal[1].GetTexture(), fx, GRAPHICSTHREAD_IMMEDIATE);
|
||||
}
|
||||
wiRenderer::GetDevice()->EventEnd(GRAPHICSTHREAD_IMMEDIATE);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ protected:
|
||||
virtual void RenderComposition(wiRenderTarget& shadedSceneRT, wiRenderTarget& mainRT, GRAPHICSTHREAD threadID);
|
||||
virtual void RenderColorGradedComposition();
|
||||
public:
|
||||
virtual wiDepthTarget* GetDepthBuffer() = 0;
|
||||
virtual const wiDepthTarget* GetDepthBuffer() = 0;
|
||||
|
||||
inline float getExposure() { return exposure; }
|
||||
inline float getLightShaftQuality(){ return lightShaftQuality; }
|
||||
|
||||
@@ -111,29 +111,29 @@ void RenderPath3D_Deferred::RenderScene(GRAPHICSTHREAD threadID)
|
||||
|
||||
wiImageParams fx((float)wiRenderer::GetInternalResolution().x, (float)wiRenderer::GetInternalResolution().y);
|
||||
|
||||
GPUResource* dsv[] = { rtGBuffer.depth->GetTexture() };
|
||||
const GPUResource* dsv[] = { &rtGBuffer.depth->GetTexture() };
|
||||
device->TransitionBarrier(dsv, ARRAYSIZE(dsv), RESOURCE_STATE_DEPTH_READ, RESOURCE_STATE_DEPTH_WRITE, threadID);
|
||||
|
||||
{
|
||||
// We can't just call rtGbuffer.Activate() because we need to inject light buffers here too so gets a bit more complicated:
|
||||
Texture2D* rts[] = {
|
||||
rtGBuffer.GetTexture(0),
|
||||
rtGBuffer.GetTexture(1),
|
||||
rtGBuffer.GetTexture(2),
|
||||
const Texture2D* rts[] = {
|
||||
&rtGBuffer.GetTexture(0),
|
||||
&rtGBuffer.GetTexture(1),
|
||||
&rtGBuffer.GetTexture(2),
|
||||
lightbuffer_diffuse.get(),
|
||||
lightbuffer_specular.get(),
|
||||
};
|
||||
device->BindRenderTargets(ARRAYSIZE(rts), rts, rtGBuffer.depth->GetTexture(), threadID);
|
||||
device->BindRenderTargets(ARRAYSIZE(rts), rts, &rtGBuffer.depth->GetTexture(), threadID);
|
||||
float clear[] = { 0,0,0,0 };
|
||||
device->ClearRenderTarget(rtGBuffer.GetTexture(1), clear, threadID);
|
||||
device->ClearDepthStencil(rtGBuffer.depth->GetTexture(), CLEAR_DEPTH | CLEAR_STENCIL, 0, 0, threadID);
|
||||
device->ClearRenderTarget(&rtGBuffer.GetTexture(1), clear, threadID);
|
||||
device->ClearDepthStencil(&rtGBuffer.depth->GetTexture(), CLEAR_DEPTH | CLEAR_STENCIL, 0, 0, threadID);
|
||||
ViewPort vp;
|
||||
vp.Width = (float)rts[0]->GetDesc().Width;
|
||||
vp.Height = (float)rts[0]->GetDesc().Height;
|
||||
device->BindViewports(1, &vp, threadID);
|
||||
|
||||
device->BindResource(PS, getReflectionsEnabled() ? rtReflection.GetTexture() : wiTextureHelper::getTransparent(), TEXSLOT_RENDERABLECOMPONENT_REFLECTION, threadID);
|
||||
device->BindResource(PS, getSSAOEnabled() ? rtSSAO.back().GetTexture() : wiTextureHelper::getWhite(), TEXSLOT_RENDERABLECOMPONENT_SSAO, threadID);
|
||||
device->BindResource(PS, getReflectionsEnabled() ? &rtReflection.GetTexture() : wiTextureHelper::getTransparent(), TEXSLOT_RENDERABLECOMPONENT_REFLECTION, threadID);
|
||||
device->BindResource(PS, getSSAOEnabled() ? &rtSSAO.back().GetTexture() : wiTextureHelper::getWhite(), TEXSLOT_RENDERABLECOMPONENT_SSAO, threadID);
|
||||
wiRenderer::DrawScene(wiRenderer::GetCamera(), getTessellationEnabled(), threadID, RENDERPASS_DEFERRED, getHairParticlesEnabled(), true, getLayerMask());
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ void RenderPath3D_Deferred::RenderScene(GRAPHICSTHREAD threadID)
|
||||
fx.sampleFlag = SAMPLEMODE_CLAMP;
|
||||
fx.quality = QUALITY_NEAREST;
|
||||
fx.process.setLinDepth();
|
||||
wiImage::Draw(rtGBuffer.depth->GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtGBuffer.depth->GetTexture(), fx, threadID);
|
||||
fx.process.clear();
|
||||
}
|
||||
rtLinearDepth.Deactivate(threadID);
|
||||
@@ -154,7 +154,7 @@ void RenderPath3D_Deferred::RenderScene(GRAPHICSTHREAD threadID)
|
||||
|
||||
device->UnbindResources(TEXSLOT_ONDEMAND0, TEXSLOT_ONDEMAND_COUNT, threadID);
|
||||
|
||||
wiRenderer::BindDepthTextures(dtDepthCopy.GetTexture(), rtLinearDepth.GetTexture(), threadID);
|
||||
wiRenderer::BindDepthTextures(&dtDepthCopy.GetTexture(), &rtLinearDepth.GetTexture(), threadID);
|
||||
|
||||
if (getStereogramEnabled())
|
||||
{
|
||||
@@ -168,7 +168,7 @@ void RenderPath3D_Deferred::RenderScene(GRAPHICSTHREAD threadID)
|
||||
}
|
||||
rtGBuffer.Deactivate(threadID);
|
||||
|
||||
wiRenderer::BindGBufferTextures(rtGBuffer.GetTexture(0), rtGBuffer.GetTexture(1), rtGBuffer.GetTexture(2), threadID);
|
||||
wiRenderer::BindGBufferTextures(&rtGBuffer.GetTexture(0), &rtGBuffer.GetTexture(1), &rtGBuffer.GetTexture(2), threadID);
|
||||
|
||||
|
||||
// Deferred lights:
|
||||
@@ -183,8 +183,8 @@ void RenderPath3D_Deferred::RenderScene(GRAPHICSTHREAD threadID)
|
||||
vp.Height = (float)rts[0]->GetDesc().Height;
|
||||
device->BindViewports(1, &vp, threadID);
|
||||
|
||||
device->BindResource(PS, getSSAOEnabled() ? rtSSAO.back().GetTexture() : wiTextureHelper::getWhite(), TEXSLOT_RENDERABLECOMPONENT_SSAO, threadID);
|
||||
device->BindResource(PS, getSSREnabled() ? rtSSR.GetTexture() : wiTextureHelper::getTransparent(), TEXSLOT_RENDERABLECOMPONENT_SSR, threadID);
|
||||
device->BindResource(PS, getSSAOEnabled() ? &rtSSAO.back().GetTexture() : wiTextureHelper::getWhite(), TEXSLOT_RENDERABLECOMPONENT_SSAO, threadID);
|
||||
device->BindResource(PS, getSSREnabled() ? &rtSSR.GetTexture() : wiTextureHelper::getTransparent(), TEXSLOT_RENDERABLECOMPONENT_SSR, threadID);
|
||||
wiRenderer::DrawLights(wiRenderer::GetCamera(), threadID);
|
||||
}
|
||||
|
||||
@@ -205,12 +205,12 @@ void RenderPath3D_Deferred::RenderScene(GRAPHICSTHREAD threadID)
|
||||
rtSSAO[1].Set(threadID); {
|
||||
fx.process.setBlur(XMFLOAT2(getSSAOBlur(), 0));
|
||||
fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
wiImage::Draw(rtSSAO[0].GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtSSAO[0].GetTexture(), fx, threadID);
|
||||
}
|
||||
rtSSAO[2].Set(threadID); {
|
||||
fx.process.setBlur(XMFLOAT2(0, getSSAOBlur()));
|
||||
fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
wiImage::Draw(rtSSAO[1].GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtSSAO[1].GetTexture(), fx, threadID);
|
||||
fx.process.clear();
|
||||
}
|
||||
fx.stencilRef = 0;
|
||||
@@ -231,7 +231,7 @@ void RenderPath3D_Deferred::RenderScene(GRAPHICSTHREAD threadID)
|
||||
for (int i = 0; i < sssPassCount; ++i)
|
||||
{
|
||||
device->UnbindResources(TEXSLOT_ONDEMAND0, 1, threadID);
|
||||
rtSSS[i % 2].Set(threadID, rtGBuffer.depth);
|
||||
rtSSS[i % 2].Set(threadID, rtGBuffer.depth.get());
|
||||
XMFLOAT2 dir = XMFLOAT2(0, 0);
|
||||
static float stren = 0.018f;
|
||||
if (i % 2 == 0)
|
||||
@@ -249,12 +249,12 @@ void RenderPath3D_Deferred::RenderScene(GRAPHICSTHREAD threadID)
|
||||
}
|
||||
else
|
||||
{
|
||||
wiImage::Draw(rtSSS[(i + 1) % 2].GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtSSS[(i + 1) % 2].GetTexture(), fx, threadID);
|
||||
}
|
||||
}
|
||||
fx.process.clear();
|
||||
device->UnbindResources(TEXSLOT_ONDEMAND0, 1, threadID);
|
||||
rtSSS[0].SetAndClear(threadID, rtGBuffer.depth); {
|
||||
rtSSS[0].SetAndClear(threadID, rtGBuffer.depth.get()); {
|
||||
fx.setMaskMap(nullptr);
|
||||
fx.quality = QUALITY_NEAREST;
|
||||
fx.sampleFlag = SAMPLEMODE_CLAMP;
|
||||
@@ -266,7 +266,7 @@ void RenderPath3D_Deferred::RenderScene(GRAPHICSTHREAD threadID)
|
||||
wiImage::Draw(lightbuffer_diffuse.get(), fx, threadID);
|
||||
fx.stencilRef = STENCILREF_SKIN;
|
||||
fx.stencilComp = STENCILMODE_LESS;
|
||||
wiImage::Draw(rtSSS[1].GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtSSS[1].GetTexture(), fx, threadID);
|
||||
}
|
||||
|
||||
fx.stencilRef = 0;
|
||||
@@ -274,9 +274,9 @@ void RenderPath3D_Deferred::RenderScene(GRAPHICSTHREAD threadID)
|
||||
device->EventEnd(threadID);
|
||||
}
|
||||
|
||||
rtDeferred.Set(threadID, rtGBuffer.depth); {
|
||||
wiImage::DrawDeferred((getSSSEnabled() ? rtSSS[0].GetTexture(0) : lightbuffer_diffuse.get()), lightbuffer_specular.get()
|
||||
, getSSAOEnabled() ? rtSSAO.back().GetTexture() : wiTextureHelper::getWhite()
|
||||
rtDeferred.Set(threadID, rtGBuffer.depth.get()); {
|
||||
wiImage::DrawDeferred((getSSSEnabled() ? &rtSSS[0].GetTexture(0) : lightbuffer_diffuse.get()), lightbuffer_specular.get()
|
||||
, getSSAOEnabled() ? &rtSSAO.back().GetTexture() : wiTextureHelper::getWhite()
|
||||
, threadID, STENCILREF_DEFAULT);
|
||||
wiRenderer::DrawSky(threadID);
|
||||
}
|
||||
@@ -289,7 +289,7 @@ void RenderPath3D_Deferred::RenderScene(GRAPHICSTHREAD threadID)
|
||||
fx.disableFullScreen();
|
||||
fx.process.setSSR();
|
||||
fx.setMaskMap(nullptr);
|
||||
wiImage::Draw(rtDeferred.GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtDeferred.GetTexture(), fx, threadID);
|
||||
fx.process.clear();
|
||||
}
|
||||
device->EventEnd(threadID);
|
||||
@@ -306,7 +306,7 @@ wiRenderTarget& RenderPath3D_Deferred::GetFinalRT()
|
||||
return rtDeferred;
|
||||
}
|
||||
|
||||
wiDepthTarget* RenderPath3D_Deferred::GetDepthBuffer()
|
||||
const wiDepthTarget* RenderPath3D_Deferred::GetDepthBuffer()
|
||||
{
|
||||
return rtGBuffer.depth;
|
||||
return rtGBuffer.depth.get();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
RenderPath3D_Deferred();
|
||||
virtual ~RenderPath3D_Deferred();
|
||||
|
||||
wiDepthTarget* GetDepthBuffer() override;
|
||||
const wiDepthTarget* GetDepthBuffer() override;
|
||||
|
||||
void Initialize() override;
|
||||
void Load() override;
|
||||
|
||||
@@ -82,21 +82,21 @@ void RenderPath3D_Forward::RenderScene(GRAPHICSTHREAD threadID)
|
||||
|
||||
wiRenderer::UpdateCameraCB(wiRenderer::GetCamera(), threadID);
|
||||
|
||||
GPUResource* dsv[] = { rtMain.depth->GetTexture() };
|
||||
const GPUResource* dsv[] = { &rtMain.depth->GetTexture() };
|
||||
wiRenderer::GetDevice()->TransitionBarrier(dsv, ARRAYSIZE(dsv), RESOURCE_STATE_DEPTH_READ, RESOURCE_STATE_DEPTH_WRITE, threadID);
|
||||
|
||||
wiImageParams fx((float)wiRenderer::GetInternalResolution().x, (float)wiRenderer::GetInternalResolution().y);
|
||||
|
||||
rtMain.SetAndClear(threadID);
|
||||
{
|
||||
wiRenderer::GetDevice()->BindResource(PS, getReflectionsEnabled() ? rtReflection.GetTexture() : wiTextureHelper::getTransparent(), TEXSLOT_RENDERABLECOMPONENT_REFLECTION, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, getSSAOEnabled() ? rtSSAO.back().GetTexture() : wiTextureHelper::getWhite(), TEXSLOT_RENDERABLECOMPONENT_SSAO, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, getSSREnabled() ? rtSSR.GetTexture() : wiTextureHelper::getTransparent(), TEXSLOT_RENDERABLECOMPONENT_SSR, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, getReflectionsEnabled() ? &rtReflection.GetTexture() : wiTextureHelper::getTransparent(), TEXSLOT_RENDERABLECOMPONENT_REFLECTION, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, getSSAOEnabled() ? &rtSSAO.back().GetTexture() : wiTextureHelper::getWhite(), TEXSLOT_RENDERABLECOMPONENT_SSAO, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, getSSREnabled() ? &rtSSR.GetTexture() : wiTextureHelper::getTransparent(), TEXSLOT_RENDERABLECOMPONENT_SSR, threadID);
|
||||
wiRenderer::DrawScene(wiRenderer::GetCamera(), getTessellationEnabled(), threadID, RENDERPASS_FORWARD, getHairParticlesEnabled(), true, getLayerMask());
|
||||
wiRenderer::DrawSky(threadID);
|
||||
}
|
||||
rtMain.Deactivate(threadID);
|
||||
wiRenderer::BindGBufferTextures(rtMain.GetTextureResolvedMSAA(threadID, 0), rtMain.GetTextureResolvedMSAA(threadID, 1), nullptr, threadID);
|
||||
wiRenderer::BindGBufferTextures(&rtMain.GetTextureResolvedMSAA(threadID, 0), &rtMain.GetTextureResolvedMSAA(threadID, 1), nullptr, threadID);
|
||||
|
||||
wiRenderer::GetDevice()->TransitionBarrier(dsv, ARRAYSIZE(dsv), RESOURCE_STATE_DEPTH_WRITE, RESOURCE_STATE_COPY_SOURCE, threadID);
|
||||
|
||||
@@ -109,12 +109,12 @@ void RenderPath3D_Forward::RenderScene(GRAPHICSTHREAD threadID)
|
||||
fx.sampleFlag = SAMPLEMODE_CLAMP;
|
||||
fx.quality = QUALITY_NEAREST;
|
||||
fx.process.setLinDepth();
|
||||
wiImage::Draw(dtDepthCopy.GetTextureResolvedMSAA(threadID), fx, threadID);
|
||||
wiImage::Draw(&dtDepthCopy.GetTextureResolvedMSAA(threadID), fx, threadID);
|
||||
fx.process.clear();
|
||||
}
|
||||
rtLinearDepth.Deactivate(threadID);
|
||||
|
||||
wiRenderer::BindDepthTextures(dtDepthCopy.GetTextureResolvedMSAA(threadID), rtLinearDepth.GetTexture(), threadID);
|
||||
wiRenderer::BindDepthTextures(&dtDepthCopy.GetTextureResolvedMSAA(threadID), &rtLinearDepth.GetTexture(), threadID);
|
||||
|
||||
|
||||
if (getSSAOEnabled()) {
|
||||
@@ -133,12 +133,12 @@ void RenderPath3D_Forward::RenderScene(GRAPHICSTHREAD threadID)
|
||||
rtSSAO[1].Set(threadID); {
|
||||
fx.process.setBlur(XMFLOAT2(getSSAOBlur(), 0));
|
||||
fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
wiImage::Draw(rtSSAO[0].GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtSSAO[0].GetTexture(), fx, threadID);
|
||||
}
|
||||
rtSSAO[2].Set(threadID); {
|
||||
fx.process.setBlur(XMFLOAT2(0, getSSAOBlur()));
|
||||
fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
wiImage::Draw(rtSSAO[1].GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtSSAO[1].GetTexture(), fx, threadID);
|
||||
fx.process.clear();
|
||||
}
|
||||
fx.stencilRef = 0;
|
||||
@@ -154,7 +154,7 @@ void RenderPath3D_Forward::RenderScene(GRAPHICSTHREAD threadID)
|
||||
fx.disableFullScreen();
|
||||
fx.process.setSSR();
|
||||
fx.setMaskMap(nullptr);
|
||||
wiImage::Draw(rtMain.GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtMain.GetTexture(), fx, threadID);
|
||||
fx.process.clear();
|
||||
}
|
||||
wiRenderer::GetDevice()->EventEnd(threadID);
|
||||
@@ -163,7 +163,7 @@ void RenderPath3D_Forward::RenderScene(GRAPHICSTHREAD threadID)
|
||||
wiProfiler::EndRange(threadID); // Opaque Scene
|
||||
}
|
||||
|
||||
wiDepthTarget* RenderPath3D_Forward::GetDepthBuffer()
|
||||
const wiDepthTarget* RenderPath3D_Forward::GetDepthBuffer()
|
||||
{
|
||||
return rtMain.depth;
|
||||
return rtMain.depth.get();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
RenderPath3D_Forward();
|
||||
virtual ~RenderPath3D_Forward();
|
||||
|
||||
wiDepthTarget* GetDepthBuffer() override;
|
||||
const wiDepthTarget* GetDepthBuffer() override;
|
||||
|
||||
void Initialize() override;
|
||||
void Load() override;
|
||||
|
||||
@@ -178,7 +178,7 @@ void RenderPath3D_PathTracing::Compose()
|
||||
fx.setDistortionMap(wiTextureHelper::getBlack()); // tonemap shader uses signed distortion mask, so black = no distortion
|
||||
fx.setMaskMap(wiTextureHelper::getColor(wiColor::Gray()));
|
||||
|
||||
wiImage::Draw(rtAccumulation.GetTexture(), fx, GRAPHICSTHREAD_IMMEDIATE);
|
||||
wiImage::Draw(&rtAccumulation.GetTexture(), fx, GRAPHICSTHREAD_IMMEDIATE);
|
||||
|
||||
|
||||
wiRenderer::GetDevice()->EventEnd(GRAPHICSTHREAD_IMMEDIATE);
|
||||
|
||||
@@ -32,29 +32,29 @@ void RenderPath3D_TiledDeferred::RenderScene(GRAPHICSTHREAD threadID)
|
||||
|
||||
wiImageParams fx((float)wiRenderer::GetInternalResolution().x, (float)wiRenderer::GetInternalResolution().y);
|
||||
|
||||
GPUResource* dsv[] = { rtGBuffer.depth->GetTexture() };
|
||||
const GPUResource* dsv[] = { &rtGBuffer.depth->GetTexture() };
|
||||
device->TransitionBarrier(dsv, ARRAYSIZE(dsv), RESOURCE_STATE_DEPTH_READ, RESOURCE_STATE_DEPTH_WRITE, threadID);
|
||||
|
||||
{
|
||||
// We can't just call rtGbuffer.Activate() because we need to inject light buffers here too so gets a bit more complicated:
|
||||
Texture2D* rts[] = {
|
||||
rtGBuffer.GetTexture(0),
|
||||
rtGBuffer.GetTexture(1),
|
||||
rtGBuffer.GetTexture(2),
|
||||
const Texture2D* rts[] = {
|
||||
&rtGBuffer.GetTexture(0),
|
||||
&rtGBuffer.GetTexture(1),
|
||||
&rtGBuffer.GetTexture(2),
|
||||
lightbuffer_diffuse.get(),
|
||||
lightbuffer_specular.get(),
|
||||
};
|
||||
device->BindRenderTargets(ARRAYSIZE(rts), rts, rtGBuffer.depth->GetTexture(), threadID);
|
||||
device->BindRenderTargets(ARRAYSIZE(rts), rts, &rtGBuffer.depth->GetTexture(), threadID);
|
||||
float clear[] = { 0,0,0,0 };
|
||||
device->ClearRenderTarget(rtGBuffer.GetTexture(1), clear, threadID);
|
||||
device->ClearDepthStencil(rtGBuffer.depth->GetTexture(), CLEAR_DEPTH | CLEAR_STENCIL, 0, 0, threadID);
|
||||
device->ClearRenderTarget(&rtGBuffer.GetTexture(1), clear, threadID);
|
||||
device->ClearDepthStencil(&rtGBuffer.depth->GetTexture(), CLEAR_DEPTH | CLEAR_STENCIL, 0, 0, threadID);
|
||||
ViewPort vp;
|
||||
vp.Width = (float)rts[0]->GetDesc().Width;
|
||||
vp.Height = (float)rts[0]->GetDesc().Height;
|
||||
device->BindViewports(1, &vp, threadID);
|
||||
|
||||
device->BindResource(PS, getReflectionsEnabled() ? rtReflection.GetTexture() : wiTextureHelper::getTransparent(), TEXSLOT_RENDERABLECOMPONENT_REFLECTION, threadID);
|
||||
device->BindResource(PS, getSSAOEnabled() ? rtSSAO.back().GetTexture() : wiTextureHelper::getWhite(), TEXSLOT_RENDERABLECOMPONENT_SSAO, threadID);
|
||||
device->BindResource(PS, getReflectionsEnabled() ? &rtReflection.GetTexture() : wiTextureHelper::getTransparent(), TEXSLOT_RENDERABLECOMPONENT_REFLECTION, threadID);
|
||||
device->BindResource(PS, getSSAOEnabled() ? &rtSSAO.back().GetTexture() : wiTextureHelper::getWhite(), TEXSLOT_RENDERABLECOMPONENT_SSAO, threadID);
|
||||
wiRenderer::DrawScene(wiRenderer::GetCamera(), getTessellationEnabled(), threadID, RENDERPASS_DEFERRED, getHairParticlesEnabled(), true, getLayerMask());
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ void RenderPath3D_TiledDeferred::RenderScene(GRAPHICSTHREAD threadID)
|
||||
fx.sampleFlag = SAMPLEMODE_CLAMP;
|
||||
fx.quality = QUALITY_NEAREST;
|
||||
fx.process.setLinDepth();
|
||||
wiImage::Draw(rtGBuffer.depth->GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtGBuffer.depth->GetTexture(), fx, threadID);
|
||||
fx.process.clear();
|
||||
}
|
||||
rtLinearDepth.Deactivate(threadID);
|
||||
@@ -77,7 +77,7 @@ void RenderPath3D_TiledDeferred::RenderScene(GRAPHICSTHREAD threadID)
|
||||
|
||||
device->UnbindResources(TEXSLOT_ONDEMAND0, TEXSLOT_ONDEMAND_COUNT, threadID);
|
||||
|
||||
wiRenderer::BindDepthTextures(dtDepthCopy.GetTexture(), rtLinearDepth.GetTexture(), threadID);
|
||||
wiRenderer::BindDepthTextures(&dtDepthCopy.GetTexture(), &rtLinearDepth.GetTexture(), threadID);
|
||||
|
||||
if (getStereogramEnabled())
|
||||
{
|
||||
@@ -91,11 +91,11 @@ void RenderPath3D_TiledDeferred::RenderScene(GRAPHICSTHREAD threadID)
|
||||
}
|
||||
rtGBuffer.Deactivate(threadID);
|
||||
|
||||
wiRenderer::BindGBufferTextures(rtGBuffer.GetTexture(0), rtGBuffer.GetTexture(1), rtGBuffer.GetTexture(2), threadID);
|
||||
wiRenderer::BindGBufferTextures(&rtGBuffer.GetTexture(0), &rtGBuffer.GetTexture(1), &rtGBuffer.GetTexture(2), threadID);
|
||||
|
||||
|
||||
device->BindResource(CS, getSSAOEnabled() ? rtSSAO.back().GetTexture() : wiTextureHelper::getWhite(), TEXSLOT_RENDERABLECOMPONENT_SSAO, threadID);
|
||||
device->BindResource(CS, getSSREnabled() ? rtSSR.GetTexture() : wiTextureHelper::getTransparent(), TEXSLOT_RENDERABLECOMPONENT_SSR, threadID);
|
||||
device->BindResource(CS, getSSAOEnabled() ? &rtSSAO.back().GetTexture() : wiTextureHelper::getWhite(), TEXSLOT_RENDERABLECOMPONENT_SSAO, threadID);
|
||||
device->BindResource(CS, getSSREnabled() ? &rtSSR.GetTexture() : wiTextureHelper::getTransparent(), TEXSLOT_RENDERABLECOMPONENT_SSR, threadID);
|
||||
|
||||
wiRenderer::ComputeTiledLightCulling(threadID, lightbuffer_diffuse.get(), lightbuffer_specular.get());
|
||||
|
||||
@@ -116,12 +116,12 @@ void RenderPath3D_TiledDeferred::RenderScene(GRAPHICSTHREAD threadID)
|
||||
rtSSAO[1].Set(threadID); {
|
||||
fx.process.setBlur(XMFLOAT2(getSSAOBlur(), 0));
|
||||
fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
wiImage::Draw(rtSSAO[0].GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtSSAO[0].GetTexture(), fx, threadID);
|
||||
}
|
||||
rtSSAO[2].Set(threadID); {
|
||||
fx.process.setBlur(XMFLOAT2(0, getSSAOBlur()));
|
||||
fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
wiImage::Draw(rtSSAO[1].GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtSSAO[1].GetTexture(), fx, threadID);
|
||||
fx.process.clear();
|
||||
}
|
||||
fx.stencilRef = 0;
|
||||
@@ -142,7 +142,7 @@ void RenderPath3D_TiledDeferred::RenderScene(GRAPHICSTHREAD threadID)
|
||||
for (int i = 0; i < sssPassCount; ++i)
|
||||
{
|
||||
device->UnbindResources(TEXSLOT_ONDEMAND0, 1, threadID);
|
||||
rtSSS[i % 2].Set(threadID, rtGBuffer.depth);
|
||||
rtSSS[i % 2].Set(threadID, rtGBuffer.depth.get());
|
||||
XMFLOAT2 dir = XMFLOAT2(0, 0);
|
||||
static float stren = 0.018f;
|
||||
if (i % 2 == 0)
|
||||
@@ -160,12 +160,12 @@ void RenderPath3D_TiledDeferred::RenderScene(GRAPHICSTHREAD threadID)
|
||||
}
|
||||
else
|
||||
{
|
||||
wiImage::Draw(rtSSS[(i + 1) % 2].GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtSSS[(i + 1) % 2].GetTexture(), fx, threadID);
|
||||
}
|
||||
}
|
||||
fx.process.clear();
|
||||
device->UnbindResources(TEXSLOT_ONDEMAND0, 1, threadID);
|
||||
rtSSS[0].SetAndClear(threadID, rtGBuffer.depth); {
|
||||
rtSSS[0].SetAndClear(threadID, rtGBuffer.depth.get()); {
|
||||
fx.setMaskMap(nullptr);
|
||||
fx.quality = QUALITY_NEAREST;
|
||||
fx.sampleFlag = SAMPLEMODE_CLAMP;
|
||||
@@ -177,7 +177,7 @@ void RenderPath3D_TiledDeferred::RenderScene(GRAPHICSTHREAD threadID)
|
||||
wiImage::Draw(static_cast<Texture2D*>(lightbuffer_diffuse.get()), fx, threadID);
|
||||
fx.stencilRef = STENCILREF_SKIN;
|
||||
fx.stencilComp = STENCILMODE_LESS;
|
||||
wiImage::Draw(rtSSS[1].GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtSSS[1].GetTexture(), fx, threadID);
|
||||
}
|
||||
|
||||
fx.stencilRef = 0;
|
||||
@@ -185,10 +185,10 @@ void RenderPath3D_TiledDeferred::RenderScene(GRAPHICSTHREAD threadID)
|
||||
device->EventEnd(threadID);
|
||||
}
|
||||
|
||||
rtDeferred.Set(threadID, rtGBuffer.depth); {
|
||||
wiImage::DrawDeferred((getSSSEnabled() ? rtSSS[0].GetTexture(0) : lightbuffer_diffuse.get()),
|
||||
rtDeferred.Set(threadID, rtGBuffer.depth.get()); {
|
||||
wiImage::DrawDeferred((getSSSEnabled() ? &rtSSS[0].GetTexture(0) : lightbuffer_diffuse.get()),
|
||||
lightbuffer_specular.get()
|
||||
, getSSAOEnabled() ? rtSSAO.back().GetTexture() : wiTextureHelper::getWhite()
|
||||
, getSSAOEnabled() ? &rtSSAO.back().GetTexture() : wiTextureHelper::getWhite()
|
||||
, threadID, STENCILREF_DEFAULT);
|
||||
wiRenderer::DrawSky(threadID);
|
||||
}
|
||||
@@ -201,7 +201,7 @@ void RenderPath3D_TiledDeferred::RenderScene(GRAPHICSTHREAD threadID)
|
||||
fx.disableFullScreen();
|
||||
fx.process.setSSR();
|
||||
fx.setMaskMap(nullptr);
|
||||
wiImage::Draw(rtDeferred.GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtDeferred.GetTexture(), fx, threadID);
|
||||
fx.process.clear();
|
||||
}
|
||||
device->EventEnd(threadID);
|
||||
@@ -214,9 +214,9 @@ void RenderPath3D_TiledDeferred::RenderTransparentScene(wiRenderTarget& refracti
|
||||
{
|
||||
wiProfiler::BeginRange("Transparent Scene", wiProfiler::DOMAIN_GPU, threadID);
|
||||
|
||||
wiRenderer::GetDevice()->BindResource(PS, getReflectionsEnabled() ? rtReflection.GetTexture() : wiTextureHelper::getTransparent(), TEXSLOT_RENDERABLECOMPONENT_REFLECTION, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, refractionRT.GetTexture(), TEXSLOT_RENDERABLECOMPONENT_REFRACTION, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, rtWaterRipple.GetTexture(), TEXSLOT_RENDERABLECOMPONENT_WATERRIPPLES, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, getReflectionsEnabled() ? &rtReflection.GetTexture() : wiTextureHelper::getTransparent(), TEXSLOT_RENDERABLECOMPONENT_REFLECTION, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, &refractionRT.GetTexture(), TEXSLOT_RENDERABLECOMPONENT_REFRACTION, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, &rtWaterRipple.GetTexture(), TEXSLOT_RENDERABLECOMPONENT_WATERRIPPLES, threadID);
|
||||
wiRenderer::DrawScene_Transparent(wiRenderer::GetCamera(), RENDERPASS_TILEDFORWARD, threadID, getHairParticlesEnabled(), true, getLayerMask());
|
||||
|
||||
wiProfiler::EndRange(); // Transparent Scene
|
||||
|
||||
@@ -19,7 +19,7 @@ void RenderPath3D_TiledForward::RenderScene(GRAPHICSTHREAD threadID)
|
||||
{
|
||||
wiRenderer::UpdateCameraCB(wiRenderer::GetCamera(), threadID);
|
||||
|
||||
GPUResource* dsv[] = { rtMain.depth->GetTexture() };
|
||||
const GPUResource* dsv[] = { &rtMain.depth->GetTexture() };
|
||||
wiRenderer::GetDevice()->TransitionBarrier(dsv, ARRAYSIZE(dsv), RESOURCE_STATE_DEPTH_READ, RESOURCE_STATE_DEPTH_WRITE, threadID);
|
||||
|
||||
wiImageParams fx((float)wiRenderer::GetInternalResolution().x, (float)wiRenderer::GetInternalResolution().y);
|
||||
@@ -42,12 +42,12 @@ void RenderPath3D_TiledForward::RenderScene(GRAPHICSTHREAD threadID)
|
||||
fx.sampleFlag = SAMPLEMODE_CLAMP;
|
||||
fx.quality = QUALITY_NEAREST;
|
||||
fx.process.setLinDepth();
|
||||
wiImage::Draw(dtDepthCopy.GetTextureResolvedMSAA(threadID), fx, threadID);
|
||||
wiImage::Draw(&dtDepthCopy.GetTextureResolvedMSAA(threadID), fx, threadID);
|
||||
fx.process.clear();
|
||||
}
|
||||
rtLinearDepth.Deactivate(threadID);
|
||||
|
||||
wiRenderer::BindDepthTextures(dtDepthCopy.GetTextureResolvedMSAA(threadID), rtLinearDepth.GetTexture(), threadID);
|
||||
wiRenderer::BindDepthTextures(&dtDepthCopy.GetTextureResolvedMSAA(threadID), &rtLinearDepth.GetTexture(), threadID);
|
||||
|
||||
wiRenderer::ComputeTiledLightCulling(threadID);
|
||||
|
||||
@@ -56,14 +56,14 @@ void RenderPath3D_TiledForward::RenderScene(GRAPHICSTHREAD threadID)
|
||||
wiProfiler::BeginRange("Opaque Scene", wiProfiler::DOMAIN_GPU, threadID);
|
||||
rtMain.Set(threadID);
|
||||
{
|
||||
wiRenderer::GetDevice()->BindResource(PS, getReflectionsEnabled() ? rtReflection.GetTexture() : wiTextureHelper::getTransparent(), TEXSLOT_RENDERABLECOMPONENT_REFLECTION, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, getSSAOEnabled() ? rtSSAO.back().GetTexture() : wiTextureHelper::getWhite(), TEXSLOT_RENDERABLECOMPONENT_SSAO, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, getSSREnabled() ? rtSSR.GetTexture() : wiTextureHelper::getTransparent(), TEXSLOT_RENDERABLECOMPONENT_SSR, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, getReflectionsEnabled() ? &rtReflection.GetTexture() : wiTextureHelper::getTransparent(), TEXSLOT_RENDERABLECOMPONENT_REFLECTION, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, getSSAOEnabled() ? &rtSSAO.back().GetTexture() : wiTextureHelper::getWhite(), TEXSLOT_RENDERABLECOMPONENT_SSAO, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, getSSREnabled() ? &rtSSR.GetTexture() : wiTextureHelper::getTransparent(), TEXSLOT_RENDERABLECOMPONENT_SSR, threadID);
|
||||
wiRenderer::DrawScene(wiRenderer::GetCamera(), getTessellationEnabled(), threadID, RENDERPASS_TILEDFORWARD, true, true);
|
||||
wiRenderer::DrawSky(threadID);
|
||||
}
|
||||
rtMain.Deactivate(threadID);
|
||||
wiRenderer::BindGBufferTextures(rtMain.GetTextureResolvedMSAA(threadID, 0), rtMain.GetTextureResolvedMSAA(threadID, 1), nullptr, threadID);
|
||||
wiRenderer::BindGBufferTextures(&rtMain.GetTextureResolvedMSAA(threadID, 0), &rtMain.GetTextureResolvedMSAA(threadID, 1), nullptr, threadID);
|
||||
|
||||
|
||||
|
||||
@@ -83,12 +83,12 @@ void RenderPath3D_TiledForward::RenderScene(GRAPHICSTHREAD threadID)
|
||||
rtSSAO[1].Set(threadID); {
|
||||
fx.process.setBlur(XMFLOAT2(getSSAOBlur(), 0));
|
||||
fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
wiImage::Draw(rtSSAO[0].GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtSSAO[0].GetTexture(), fx, threadID);
|
||||
}
|
||||
rtSSAO[2].Set(threadID); {
|
||||
fx.process.setBlur(XMFLOAT2(0, getSSAOBlur()));
|
||||
fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
wiImage::Draw(rtSSAO[1].GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtSSAO[1].GetTexture(), fx, threadID);
|
||||
fx.process.clear();
|
||||
}
|
||||
fx.stencilRef = 0;
|
||||
@@ -104,7 +104,7 @@ void RenderPath3D_TiledForward::RenderScene(GRAPHICSTHREAD threadID)
|
||||
fx.disableFullScreen();
|
||||
fx.process.setSSR();
|
||||
fx.setMaskMap(nullptr);
|
||||
wiImage::Draw(rtMain.GetTexture(), fx, threadID);
|
||||
wiImage::Draw(&rtMain.GetTexture(), fx, threadID);
|
||||
fx.process.clear();
|
||||
}
|
||||
wiRenderer::GetDevice()->EventEnd(threadID);
|
||||
@@ -116,9 +116,9 @@ void RenderPath3D_TiledForward::RenderTransparentScene(wiRenderTarget& refractio
|
||||
{
|
||||
wiProfiler::BeginRange("Transparent Scene", wiProfiler::DOMAIN_GPU, threadID);
|
||||
|
||||
wiRenderer::GetDevice()->BindResource(PS, getReflectionsEnabled() ? rtReflection.GetTexture() : wiTextureHelper::getTransparent(), TEXSLOT_RENDERABLECOMPONENT_REFLECTION, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, refractionRT.GetTexture(), TEXSLOT_RENDERABLECOMPONENT_REFRACTION, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, rtWaterRipple.GetTexture(), TEXSLOT_RENDERABLECOMPONENT_WATERRIPPLES, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, getReflectionsEnabled() ? &rtReflection.GetTexture() : wiTextureHelper::getTransparent(), TEXSLOT_RENDERABLECOMPONENT_REFLECTION, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, &refractionRT.GetTexture(), TEXSLOT_RENDERABLECOMPONENT_REFRACTION, threadID);
|
||||
wiRenderer::GetDevice()->BindResource(PS, &rtWaterRipple.GetTexture(), TEXSLOT_RENDERABLECOMPONENT_WATERRIPPLES, threadID);
|
||||
wiRenderer::DrawScene_Transparent(wiRenderer::GetCamera(), RENDERPASS_TILEDFORWARD, threadID, getHairParticlesEnabled(), true);
|
||||
|
||||
wiProfiler::EndRange(threadID); // Transparent Scene
|
||||
|
||||
@@ -885,7 +885,7 @@
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{8C15DC72-70C8-4212-B046-0B166A688A7C}</ProjectGuid>
|
||||
<RootNamespace>WickedEngine_SHADERS</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
|
||||
<AppContainerApplication>true</AppContainerApplication>
|
||||
<ApplicationType>Windows Store</ApplicationType>
|
||||
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
|
||||
<WindowsTargetPlatformMinVersion>10.0.15063.0</WindowsTargetPlatformMinVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<ProjectGuid>{06163DCB-B183-4ED9-9C62-13EF1658E049}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>WickedEngine_Windows</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
|
||||
@@ -3,94 +3,75 @@
|
||||
|
||||
using namespace wiGraphicsTypes;
|
||||
|
||||
wiDepthTarget::wiDepthTarget()
|
||||
{
|
||||
texture = nullptr;
|
||||
texture_resolvedMSAA = nullptr;
|
||||
resolvedMSAAUptodate = false;
|
||||
}
|
||||
|
||||
|
||||
wiDepthTarget::~wiDepthTarget()
|
||||
{
|
||||
}
|
||||
|
||||
void wiDepthTarget::Initialize(int width, int height, UINT MSAAC)
|
||||
{
|
||||
resolvedMSAAUptodate = false;
|
||||
dirty = true;
|
||||
|
||||
TextureDesc depthDesc;
|
||||
|
||||
// Set up the description of the depth buffer.
|
||||
depthDesc.Width = width;
|
||||
depthDesc.Height = height;
|
||||
depthDesc.MipLevels = 1;
|
||||
depthDesc.ArraySize = 1;
|
||||
depthDesc.Format = wiRenderer::DSFormat_full_alias;
|
||||
depthDesc.SampleDesc.Count = MSAAC;
|
||||
TextureDesc desc;
|
||||
desc.Width = width;
|
||||
desc.Height = height;
|
||||
desc.MipLevels = 1;
|
||||
desc.ArraySize = 1;
|
||||
desc.Format = wiRenderer::DSFormat_full_alias;
|
||||
desc.SampleDesc.Count = MSAAC;
|
||||
// depthDesc.SampleDesc.Quality = 0; // auto-filll in device
|
||||
depthDesc.Usage = USAGE_DEFAULT;
|
||||
depthDesc.BindFlags = BIND_DEPTH_STENCIL | BIND_SHADER_RESOURCE;
|
||||
depthDesc.CPUAccessFlags = 0;
|
||||
depthDesc.MiscFlags = 0;
|
||||
desc.Usage = USAGE_DEFAULT;
|
||||
desc.BindFlags = BIND_DEPTH_STENCIL | BIND_SHADER_RESOURCE;
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.MiscFlags = 0;
|
||||
|
||||
texture.reset(new Texture2D);
|
||||
wiRenderer::GetDevice()->CreateTexture2D(&depthDesc, nullptr, texture.get());
|
||||
wiRenderer::GetDevice()->CreateTexture2D(&desc, nullptr, &target_primary);
|
||||
|
||||
if (MSAAC > 1)
|
||||
{
|
||||
depthDesc.SampleDesc.Count = 1;
|
||||
depthDesc.Format = wiRenderer::RTFormat_depthresolve;
|
||||
depthDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS;
|
||||
texture_resolvedMSAA.reset(new Texture2D);
|
||||
wiRenderer::GetDevice()->CreateTexture2D(&depthDesc, nullptr, texture_resolvedMSAA.get());
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.Format = wiRenderer::RTFormat_depthresolve;
|
||||
desc.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS;
|
||||
wiRenderer::GetDevice()->CreateTexture2D(&desc, nullptr, &target_resolved);
|
||||
}
|
||||
}
|
||||
void wiDepthTarget::InitializeCube(int size, bool independentFaces)
|
||||
{
|
||||
resolvedMSAAUptodate = false;
|
||||
dirty = true;
|
||||
|
||||
TextureDesc depthGPUBufferDesc;
|
||||
TextureDesc desc;
|
||||
desc.Width = size;
|
||||
desc.Height = size;
|
||||
desc.MipLevels = 1;
|
||||
desc.ArraySize = 6;
|
||||
desc.Format = wiRenderer::DSFormat_small_alias;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.SampleDesc.Quality = 0;
|
||||
desc.Usage = USAGE_DEFAULT;
|
||||
desc.BindFlags = BIND_DEPTH_STENCIL | BIND_SHADER_RESOURCE;
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.MiscFlags = RESOURCE_MISC_TEXTURECUBE;
|
||||
|
||||
// Set up the description of the depth buffer.
|
||||
depthGPUBufferDesc.Width = size;
|
||||
depthGPUBufferDesc.Height = size;
|
||||
depthGPUBufferDesc.MipLevels = 1;
|
||||
depthGPUBufferDesc.ArraySize = 6;
|
||||
depthGPUBufferDesc.Format = wiRenderer::DSFormat_small_alias;
|
||||
depthGPUBufferDesc.SampleDesc.Count = 1;
|
||||
depthGPUBufferDesc.SampleDesc.Quality = 0;
|
||||
depthGPUBufferDesc.Usage = USAGE_DEFAULT;
|
||||
depthGPUBufferDesc.BindFlags = BIND_DEPTH_STENCIL | BIND_SHADER_RESOURCE;
|
||||
depthGPUBufferDesc.CPUAccessFlags = 0;
|
||||
depthGPUBufferDesc.MiscFlags = RESOURCE_MISC_TEXTURECUBE;
|
||||
|
||||
texture.reset(new Texture2D);
|
||||
texture->RequestIndependentRenderTargetCubemapFaces(independentFaces);
|
||||
wiRenderer::GetDevice()->CreateTexture2D(&depthGPUBufferDesc, nullptr, texture.get());
|
||||
target_primary.RequestIndependentRenderTargetCubemapFaces(independentFaces);
|
||||
wiRenderer::GetDevice()->CreateTexture2D(&desc, nullptr, &target_primary);
|
||||
}
|
||||
|
||||
void wiDepthTarget::Clear(GRAPHICSTHREAD threadID)
|
||||
{
|
||||
wiRenderer::GetDevice()->ClearDepthStencil(GetTexture(), CLEAR_DEPTH | CLEAR_STENCIL, 0.0f, 0, threadID);
|
||||
resolvedMSAAUptodate = false;
|
||||
wiRenderer::GetDevice()->ClearDepthStencil(&GetTexture(), CLEAR_DEPTH | CLEAR_STENCIL, 0.0f, 0, threadID);
|
||||
dirty = true;
|
||||
}
|
||||
void wiDepthTarget::CopyFrom(const wiDepthTarget& from, GRAPHICSTHREAD threadID)
|
||||
{
|
||||
wiRenderer::GetDevice()->CopyTexture2D(GetTexture(), from.GetTexture(), threadID);
|
||||
resolvedMSAAUptodate = false;
|
||||
wiRenderer::GetDevice()->CopyTexture2D(&GetTexture(), &from.GetTexture(), threadID);
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
Texture2D* wiDepthTarget::GetTextureResolvedMSAA(GRAPHICSTHREAD threadID)
|
||||
const Texture2D& wiDepthTarget::GetTextureResolvedMSAA(GRAPHICSTHREAD threadID)
|
||||
{
|
||||
if (texture_resolvedMSAA != nullptr)
|
||||
if (GetDesc().SampleDesc.Count > 1)
|
||||
{
|
||||
if (!resolvedMSAAUptodate)
|
||||
if (dirty)
|
||||
{
|
||||
wiRenderer::ResolveMSAADepthBuffer(texture_resolvedMSAA.get(), texture.get(), threadID);
|
||||
resolvedMSAAUptodate = true;
|
||||
wiRenderer::ResolveMSAADepthBuffer(&target_resolved, &target_primary, threadID);
|
||||
dirty = false;
|
||||
}
|
||||
return texture_resolvedMSAA.get();
|
||||
return target_resolved;
|
||||
}
|
||||
return texture.get();
|
||||
return target_primary;
|
||||
}
|
||||
|
||||
@@ -7,21 +7,18 @@
|
||||
class wiDepthTarget
|
||||
{
|
||||
private:
|
||||
std::unique_ptr<wiGraphicsTypes::Texture2D> texture;
|
||||
std::unique_ptr<wiGraphicsTypes::Texture2D> texture_resolvedMSAA;
|
||||
bool resolvedMSAAUptodate;
|
||||
wiGraphicsTypes::Texture2D target_primary;
|
||||
wiGraphicsTypes::Texture2D target_resolved;
|
||||
bool dirty = true;
|
||||
public:
|
||||
|
||||
wiDepthTarget();
|
||||
~wiDepthTarget();
|
||||
|
||||
void Initialize(int width, int height, UINT MSAAC);
|
||||
void InitializeCube(int size, bool independentFaces = false);
|
||||
void Clear(GRAPHICSTHREAD threadID);
|
||||
void CopyFrom(const wiDepthTarget&, GRAPHICSTHREAD threadID);
|
||||
|
||||
wiGraphicsTypes::Texture2D* GetTexture() const { return texture.get(); }
|
||||
wiGraphicsTypes::Texture2D* GetTextureResolvedMSAA(GRAPHICSTHREAD threadID);
|
||||
wiGraphicsTypes::TextureDesc GetDesc() const { return GetTexture()->GetDesc(); }
|
||||
const wiGraphicsTypes::Texture2D& GetTexture() const { return target_primary; }
|
||||
const wiGraphicsTypes::Texture2D& GetTextureResolvedMSAA(GRAPHICSTHREAD threadID);
|
||||
const wiGraphicsTypes::TextureDesc& GetDesc() const { return GetTexture().GetDesc(); }
|
||||
};
|
||||
|
||||
|
||||
@@ -2851,11 +2851,13 @@ void GraphicsDevice_DX11::DestroyResource(GPUResource* pResource)
|
||||
if (pResource->resource != WI_NULL_HANDLE)
|
||||
{
|
||||
((ID3D11Resource*)pResource->resource)->Release();
|
||||
pResource->resource = WI_NULL_HANDLE;
|
||||
}
|
||||
|
||||
if (pResource->SRV != WI_NULL_HANDLE)
|
||||
{
|
||||
((ID3D11ShaderResourceView*)pResource->SRV)->Release();
|
||||
pResource->SRV = WI_NULL_HANDLE;
|
||||
}
|
||||
for (auto& x : pResource->additionalSRVs)
|
||||
{
|
||||
@@ -2864,10 +2866,12 @@ void GraphicsDevice_DX11::DestroyResource(GPUResource* pResource)
|
||||
((ID3D11ShaderResourceView*)x)->Release();
|
||||
}
|
||||
}
|
||||
pResource->additionalSRVs.clear();
|
||||
|
||||
if (pResource->UAV != WI_NULL_HANDLE)
|
||||
{
|
||||
((ID3D11UnorderedAccessView*)pResource->UAV)->Release();
|
||||
pResource->UAV = WI_NULL_HANDLE;
|
||||
}
|
||||
for (auto& x : pResource->additionalUAVs)
|
||||
{
|
||||
@@ -2876,6 +2880,7 @@ void GraphicsDevice_DX11::DestroyResource(GPUResource* pResource)
|
||||
((ID3D11UnorderedAccessView*)x)->Release();
|
||||
}
|
||||
}
|
||||
pResource->additionalUAVs.clear();
|
||||
}
|
||||
void GraphicsDevice_DX11::DestroyBuffer(GPUBuffer *pBuffer)
|
||||
{
|
||||
@@ -2885,6 +2890,7 @@ void GraphicsDevice_DX11::DestroyTexture1D(Texture1D *pTexture1D)
|
||||
if (pTexture1D->RTV != WI_NULL_HANDLE)
|
||||
{
|
||||
((ID3D11RenderTargetView*)pTexture1D->RTV)->Release();
|
||||
pTexture1D->RTV = WI_NULL_HANDLE;
|
||||
}
|
||||
for (auto& x : pTexture1D->additionalRTVs)
|
||||
{
|
||||
@@ -2893,12 +2899,14 @@ void GraphicsDevice_DX11::DestroyTexture1D(Texture1D *pTexture1D)
|
||||
((ID3D11RenderTargetView*)x)->Release();
|
||||
}
|
||||
}
|
||||
pTexture1D->additionalRTVs.clear();
|
||||
}
|
||||
void GraphicsDevice_DX11::DestroyTexture2D(Texture2D *pTexture2D)
|
||||
{
|
||||
if (pTexture2D->RTV != WI_NULL_HANDLE)
|
||||
{
|
||||
((ID3D11RenderTargetView*)pTexture2D->RTV)->Release();
|
||||
pTexture2D->RTV = WI_NULL_HANDLE;
|
||||
}
|
||||
for (auto& x : pTexture2D->additionalRTVs)
|
||||
{
|
||||
@@ -2907,10 +2915,12 @@ void GraphicsDevice_DX11::DestroyTexture2D(Texture2D *pTexture2D)
|
||||
((ID3D11RenderTargetView*)x)->Release();
|
||||
}
|
||||
}
|
||||
pTexture2D->additionalRTVs.clear();
|
||||
|
||||
if (pTexture2D->DSV != WI_NULL_HANDLE)
|
||||
{
|
||||
((ID3D11DepthStencilView*)pTexture2D->DSV)->Release();
|
||||
pTexture2D->DSV = WI_NULL_HANDLE;
|
||||
}
|
||||
for (auto& x : pTexture2D->additionalDSVs)
|
||||
{
|
||||
@@ -2919,6 +2929,7 @@ void GraphicsDevice_DX11::DestroyTexture2D(Texture2D *pTexture2D)
|
||||
((ID3D11DepthStencilView*)x)->Release();
|
||||
}
|
||||
}
|
||||
pTexture2D->additionalDSVs.clear();
|
||||
}
|
||||
void GraphicsDevice_DX11::DestroyTexture3D(Texture3D *pTexture3D)
|
||||
{
|
||||
@@ -2933,12 +2944,14 @@ void GraphicsDevice_DX11::DestroyTexture3D(Texture3D *pTexture3D)
|
||||
((ID3D11RenderTargetView*)x)->Release();
|
||||
}
|
||||
}
|
||||
pTexture3D->additionalRTVs.clear();
|
||||
}
|
||||
void GraphicsDevice_DX11::DestroyInputLayout(VertexLayout *pInputLayout)
|
||||
{
|
||||
if (pInputLayout->resource != WI_NULL_HANDLE)
|
||||
{
|
||||
((ID3D11InputLayout*)pInputLayout->resource)->Release();
|
||||
pInputLayout->resource = WI_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
void GraphicsDevice_DX11::DestroyVertexShader(VertexShader *pVertexShader)
|
||||
@@ -2946,6 +2959,7 @@ void GraphicsDevice_DX11::DestroyVertexShader(VertexShader *pVertexShader)
|
||||
if (pVertexShader->resource != WI_NULL_HANDLE)
|
||||
{
|
||||
((ID3D11VertexShader*)pVertexShader->resource)->Release();
|
||||
pVertexShader->resource = WI_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
void GraphicsDevice_DX11::DestroyPixelShader(PixelShader *pPixelShader)
|
||||
@@ -2953,6 +2967,7 @@ void GraphicsDevice_DX11::DestroyPixelShader(PixelShader *pPixelShader)
|
||||
if (pPixelShader->resource != WI_NULL_HANDLE)
|
||||
{
|
||||
((ID3D11PixelShader*)pPixelShader->resource)->Release();
|
||||
pPixelShader->resource = WI_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
void GraphicsDevice_DX11::DestroyGeometryShader(GeometryShader *pGeometryShader)
|
||||
@@ -2960,6 +2975,7 @@ void GraphicsDevice_DX11::DestroyGeometryShader(GeometryShader *pGeometryShader)
|
||||
if (pGeometryShader->resource != WI_NULL_HANDLE)
|
||||
{
|
||||
((ID3D11GeometryShader*)pGeometryShader->resource)->Release();
|
||||
pGeometryShader->resource = WI_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
void GraphicsDevice_DX11::DestroyHullShader(HullShader *pHullShader)
|
||||
@@ -2967,6 +2983,7 @@ void GraphicsDevice_DX11::DestroyHullShader(HullShader *pHullShader)
|
||||
if (pHullShader->resource != WI_NULL_HANDLE)
|
||||
{
|
||||
((ID3D11HullShader*)pHullShader->resource)->Release();
|
||||
pHullShader->resource = WI_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
void GraphicsDevice_DX11::DestroyDomainShader(DomainShader *pDomainShader)
|
||||
@@ -2974,6 +2991,7 @@ void GraphicsDevice_DX11::DestroyDomainShader(DomainShader *pDomainShader)
|
||||
if (pDomainShader->resource != WI_NULL_HANDLE)
|
||||
{
|
||||
((ID3D11DomainShader*)pDomainShader->resource)->Release();
|
||||
pDomainShader->resource = WI_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
void GraphicsDevice_DX11::DestroyComputeShader(ComputeShader *pComputeShader)
|
||||
@@ -2981,6 +2999,7 @@ void GraphicsDevice_DX11::DestroyComputeShader(ComputeShader *pComputeShader)
|
||||
if (pComputeShader->resource != WI_NULL_HANDLE)
|
||||
{
|
||||
((ID3D11ComputeShader*)pComputeShader->resource)->Release();
|
||||
pComputeShader->resource = WI_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
void GraphicsDevice_DX11::DestroyBlendState(BlendState *pBlendState)
|
||||
@@ -2988,6 +3007,7 @@ void GraphicsDevice_DX11::DestroyBlendState(BlendState *pBlendState)
|
||||
if (pBlendState->resource != WI_NULL_HANDLE)
|
||||
{
|
||||
((ID3D11BlendState*)pBlendState->resource)->Release();
|
||||
pBlendState->resource = WI_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
void GraphicsDevice_DX11::DestroyDepthStencilState(DepthStencilState *pDepthStencilState)
|
||||
@@ -2995,6 +3015,7 @@ void GraphicsDevice_DX11::DestroyDepthStencilState(DepthStencilState *pDepthSten
|
||||
if (pDepthStencilState->resource != WI_NULL_HANDLE)
|
||||
{
|
||||
((ID3D11DepthStencilState*)pDepthStencilState->resource)->Release();
|
||||
pDepthStencilState->resource = WI_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
void GraphicsDevice_DX11::DestroyRasterizerState(RasterizerState *pRasterizerState)
|
||||
@@ -3002,6 +3023,7 @@ void GraphicsDevice_DX11::DestroyRasterizerState(RasterizerState *pRasterizerSta
|
||||
if (pRasterizerState->resource != WI_NULL_HANDLE)
|
||||
{
|
||||
((ID3D11RasterizerState*)pRasterizerState->resource)->Release();
|
||||
pRasterizerState->resource = WI_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
void GraphicsDevice_DX11::DestroySamplerState(Sampler *pSamplerState)
|
||||
@@ -3009,6 +3031,7 @@ void GraphicsDevice_DX11::DestroySamplerState(Sampler *pSamplerState)
|
||||
if (pSamplerState->resource != WI_NULL_HANDLE)
|
||||
{
|
||||
((ID3D11SamplerState*)pSamplerState->resource)->Release();
|
||||
pSamplerState->resource = WI_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
void GraphicsDevice_DX11::DestroyQuery(GPUQuery *pQuery)
|
||||
@@ -3016,6 +3039,7 @@ void GraphicsDevice_DX11::DestroyQuery(GPUQuery *pQuery)
|
||||
if (pQuery->resource != WI_NULL_HANDLE)
|
||||
{
|
||||
((ID3D11Query*)pQuery->resource)->Release();
|
||||
pQuery->resource = WI_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
void GraphicsDevice_DX11::DestroyGraphicsPSO(GraphicsPSO* pso)
|
||||
@@ -3202,8 +3226,7 @@ void GraphicsDevice_DX11::BindViewports(UINT NumViewports, const ViewPort *pView
|
||||
void GraphicsDevice_DX11::BindRenderTargets(UINT NumViews, const Texture2D* const *ppRenderTargets, const Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID, int arrayIndex)
|
||||
{
|
||||
// RTVs:
|
||||
ID3D11RenderTargetView* renderTargetViews[8];
|
||||
ZeroMemory(renderTargetViews, sizeof(renderTargetViews));
|
||||
ID3D11RenderTargetView* renderTargetViews[8] = {};
|
||||
for (UINT i = 0; i < min(NumViews, 8); ++i)
|
||||
{
|
||||
if (arrayIndex < 0 || ppRenderTargets[i]->additionalRTVs.empty())
|
||||
|
||||
@@ -3197,53 +3197,67 @@ namespace wiGraphicsTypes
|
||||
if (pResource->resource != WI_NULL_HANDLE)
|
||||
{
|
||||
((ID3D12Resource*)pResource->resource)->Release();
|
||||
pResource->resource = WI_NULL_HANDLE;
|
||||
}
|
||||
|
||||
ResourceAllocator->free(pResource->SRV);
|
||||
pResource->SRV = WI_NULL_HANDLE;
|
||||
for (auto& x : pResource->additionalSRVs)
|
||||
{
|
||||
ResourceAllocator->free(x);
|
||||
}
|
||||
pResource->additionalSRVs.clear();
|
||||
|
||||
ResourceAllocator->free(pResource->UAV);
|
||||
pResource->UAV = WI_NULL_HANDLE;
|
||||
for (auto& x : pResource->additionalUAVs)
|
||||
{
|
||||
ResourceAllocator->free(x);
|
||||
}
|
||||
pResource->additionalUAVs.clear();
|
||||
}
|
||||
void GraphicsDevice_DX12::DestroyBuffer(GPUBuffer *pBuffer)
|
||||
{
|
||||
ResourceAllocator->free(pBuffer->CBV);
|
||||
pBuffer->CBV = WI_NULL_HANDLE;
|
||||
}
|
||||
void GraphicsDevice_DX12::DestroyTexture1D(Texture1D *pTexture1D)
|
||||
{
|
||||
RTAllocator->free(pTexture1D->RTV);
|
||||
pTexture1D->RTV = WI_NULL_HANDLE;
|
||||
for (auto& x : pTexture1D->additionalRTVs)
|
||||
{
|
||||
RTAllocator->free(x);
|
||||
}
|
||||
pTexture1D->additionalRTVs.clear();
|
||||
}
|
||||
void GraphicsDevice_DX12::DestroyTexture2D(Texture2D *pTexture2D)
|
||||
{
|
||||
RTAllocator->free(pTexture2D->RTV);
|
||||
pTexture2D->RTV = WI_NULL_HANDLE;
|
||||
for (auto& x : pTexture2D->additionalRTVs)
|
||||
{
|
||||
RTAllocator->free(x);
|
||||
}
|
||||
pTexture2D->additionalRTVs.clear();
|
||||
|
||||
DSAllocator->free(pTexture2D->DSV);
|
||||
pTexture2D->DSV = WI_NULL_HANDLE;
|
||||
for (auto& x : pTexture2D->additionalDSVs)
|
||||
{
|
||||
DSAllocator->free(x);
|
||||
}
|
||||
pTexture2D->additionalDSVs.clear();
|
||||
}
|
||||
void GraphicsDevice_DX12::DestroyTexture3D(Texture3D *pTexture3D)
|
||||
{
|
||||
RTAllocator->free(pTexture3D->RTV);
|
||||
pTexture3D->RTV = WI_NULL_HANDLE;
|
||||
for (auto& x : pTexture3D->additionalRTVs)
|
||||
{
|
||||
RTAllocator->free(x);
|
||||
}
|
||||
pTexture3D->additionalRTVs.clear();
|
||||
}
|
||||
void GraphicsDevice_DX12::DestroyInputLayout(VertexLayout *pInputLayout)
|
||||
{
|
||||
@@ -3298,6 +3312,7 @@ namespace wiGraphicsTypes
|
||||
if (pso->pipeline != WI_NULL_HANDLE)
|
||||
{
|
||||
((ID3D12PipelineState*)pso->pipeline)->Release();
|
||||
pso->pipeline = WI_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
void GraphicsDevice_DX12::DestroyComputePSO(ComputePSO* pso)
|
||||
@@ -3305,6 +3320,7 @@ namespace wiGraphicsTypes
|
||||
if (pso->pipeline != WI_NULL_HANDLE)
|
||||
{
|
||||
((ID3D12PipelineState*)pso->pipeline)->Release();
|
||||
pso->pipeline = WI_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4018,94 +4018,123 @@ namespace wiGraphicsTypes
|
||||
void GraphicsDevice_Vulkan::DestroyResource(GPUResource* pResource)
|
||||
{
|
||||
vkFreeMemory(device, (VkDeviceMemory)pResource->resourceMemory, nullptr);
|
||||
pResource->resourceMemory = WI_NULL_HANDLE;
|
||||
}
|
||||
void GraphicsDevice_Vulkan::DestroyBuffer(GPUBuffer *pBuffer)
|
||||
{
|
||||
vkDestroyBuffer(device, (VkBuffer)pBuffer->resource, nullptr);
|
||||
pBuffer->resource = WI_NULL_HANDLE;
|
||||
|
||||
vkDestroyBufferView(device, (VkBufferView)pBuffer->SRV, nullptr);
|
||||
pBuffer->SRV = WI_NULL_HANDLE;
|
||||
for (auto& x : pBuffer->additionalSRVs)
|
||||
{
|
||||
vkDestroyBufferView(device, (VkBufferView)x, nullptr);
|
||||
}
|
||||
pBuffer->additionalSRVs.clear();
|
||||
|
||||
vkDestroyBufferView(device, (VkBufferView)pBuffer->UAV, nullptr);
|
||||
pBuffer->UAV = WI_NULL_HANDLE;
|
||||
for (auto& x : pBuffer->additionalUAVs)
|
||||
{
|
||||
vkDestroyBufferView(device, (VkBufferView)x, nullptr);
|
||||
}
|
||||
pBuffer->additionalUAVs.clear();
|
||||
}
|
||||
void GraphicsDevice_Vulkan::DestroyTexture1D(Texture1D *pTexture1D)
|
||||
{
|
||||
vkDestroyImage(device, (VkImage)pTexture1D->resource, nullptr);
|
||||
pTexture1D->resource = WI_NULL_HANDLE;
|
||||
|
||||
vkDestroyImageView(device, (VkImageView)pTexture1D->RTV, nullptr);
|
||||
pTexture1D->RTV = WI_NULL_HANDLE;
|
||||
for (auto& x : pTexture1D->additionalRTVs)
|
||||
{
|
||||
vkDestroyImageView(device, (VkImageView)x, nullptr);
|
||||
}
|
||||
pTexture1D->additionalRTVs.clear();
|
||||
|
||||
vkDestroyImageView(device, (VkImageView)pTexture1D->SRV, nullptr);
|
||||
pTexture1D->SRV = WI_NULL_HANDLE;
|
||||
for (auto& x : pTexture1D->additionalSRVs)
|
||||
{
|
||||
vkDestroyImageView(device, (VkImageView)x, nullptr);
|
||||
}
|
||||
pTexture1D->additionalSRVs.clear();
|
||||
|
||||
vkDestroyImageView(device, (VkImageView)pTexture1D->UAV, nullptr);
|
||||
pTexture1D->UAV = WI_NULL_HANDLE;
|
||||
for (auto& x : pTexture1D->additionalUAVs)
|
||||
{
|
||||
vkDestroyImageView(device, (VkImageView)x, nullptr);
|
||||
}
|
||||
pTexture1D->additionalUAVs.clear();
|
||||
}
|
||||
void GraphicsDevice_Vulkan::DestroyTexture2D(Texture2D *pTexture2D)
|
||||
{
|
||||
vkDestroyImage(device, (VkImage)pTexture2D->resource, nullptr);
|
||||
pTexture2D->resource = WI_NULL_HANDLE;
|
||||
|
||||
vkDestroyImageView(device, (VkImageView)pTexture2D->RTV, nullptr);
|
||||
pTexture2D->RTV = WI_NULL_HANDLE;
|
||||
for (auto& x : pTexture2D->additionalRTVs)
|
||||
{
|
||||
vkDestroyImageView(device, (VkImageView)x, nullptr);
|
||||
}
|
||||
pTexture2D->additionalRTVs.clear();
|
||||
|
||||
vkDestroyImageView(device, (VkImageView)pTexture2D->DSV, nullptr);
|
||||
pTexture2D->DSV = WI_NULL_HANDLE;
|
||||
for (auto& x : pTexture2D->additionalDSVs)
|
||||
{
|
||||
vkDestroyImageView(device, (VkImageView)x, nullptr);
|
||||
}
|
||||
pTexture2D->additionalDSVs.clear();
|
||||
|
||||
vkDestroyImageView(device, (VkImageView)pTexture2D->SRV, nullptr);
|
||||
pTexture2D->SRV = WI_NULL_HANDLE;
|
||||
for (auto& x : pTexture2D->additionalSRVs)
|
||||
{
|
||||
vkDestroyImageView(device, (VkImageView)x, nullptr);
|
||||
}
|
||||
pTexture2D->additionalSRVs.clear();
|
||||
|
||||
vkDestroyImageView(device, (VkImageView)pTexture2D->UAV, nullptr);
|
||||
pTexture2D->UAV = WI_NULL_HANDLE;
|
||||
for (auto& x : pTexture2D->additionalUAVs)
|
||||
{
|
||||
vkDestroyImageView(device, (VkImageView)x, nullptr);
|
||||
}
|
||||
pTexture2D->additionalUAVs.clear();
|
||||
}
|
||||
void GraphicsDevice_Vulkan::DestroyTexture3D(Texture3D *pTexture3D)
|
||||
{
|
||||
vkDestroyImage(device, (VkImage)pTexture3D->resource, nullptr);
|
||||
pTexture3D->resource = WI_NULL_HANDLE;
|
||||
|
||||
vkDestroyImageView(device, (VkImageView)pTexture3D->RTV, nullptr);
|
||||
pTexture3D->RTV = WI_NULL_HANDLE;
|
||||
for (auto& x : pTexture3D->additionalRTVs)
|
||||
{
|
||||
vkDestroyImageView(device, (VkImageView)x, nullptr);
|
||||
}
|
||||
pTexture3D->additionalRTVs.clear();
|
||||
|
||||
vkDestroyImageView(device, (VkImageView)pTexture3D->SRV, nullptr);
|
||||
pTexture3D->SRV = WI_NULL_HANDLE;
|
||||
for (auto& x : pTexture3D->additionalSRVs)
|
||||
{
|
||||
vkDestroyImageView(device, (VkImageView)x, nullptr);
|
||||
}
|
||||
pTexture3D->additionalSRVs.clear();
|
||||
|
||||
vkDestroyImageView(device, (VkImageView)pTexture3D->UAV, nullptr);
|
||||
pTexture3D->UAV = WI_NULL_HANDLE;
|
||||
for (auto& x : pTexture3D->additionalUAVs)
|
||||
{
|
||||
vkDestroyImageView(device, (VkImageView)x, nullptr);
|
||||
}
|
||||
pTexture3D->additionalUAVs.clear();
|
||||
}
|
||||
void GraphicsDevice_Vulkan::DestroyInputLayout(VertexLayout *pInputLayout)
|
||||
{
|
||||
@@ -4158,10 +4187,12 @@ namespace wiGraphicsTypes
|
||||
void GraphicsDevice_Vulkan::DestroyGraphicsPSO(GraphicsPSO* pso)
|
||||
{
|
||||
vkDestroyPipeline(device, (VkPipeline)pso->pipeline, nullptr);
|
||||
pso->pipeline = WI_NULL_HANDLE;
|
||||
}
|
||||
void GraphicsDevice_Vulkan::DestroyComputePSO(ComputePSO* pso)
|
||||
{
|
||||
vkDestroyPipeline(device, (VkPipeline)pso->pipeline, nullptr);
|
||||
pso->pipeline = WI_NULL_HANDLE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
|
||||
namespace wiGraphicsTypes
|
||||
{
|
||||
VertexShader::VertexShader()
|
||||
{
|
||||
}
|
||||
VertexShader::~VertexShader()
|
||||
{
|
||||
if (device != nullptr)
|
||||
@@ -14,9 +11,6 @@ namespace wiGraphicsTypes
|
||||
}
|
||||
}
|
||||
|
||||
PixelShader::PixelShader()
|
||||
{
|
||||
}
|
||||
PixelShader::~PixelShader()
|
||||
{
|
||||
if (device != nullptr)
|
||||
@@ -25,9 +19,6 @@ namespace wiGraphicsTypes
|
||||
}
|
||||
}
|
||||
|
||||
GeometryShader::GeometryShader()
|
||||
{
|
||||
}
|
||||
GeometryShader::~GeometryShader()
|
||||
{
|
||||
if (device != nullptr)
|
||||
@@ -36,9 +27,6 @@ namespace wiGraphicsTypes
|
||||
}
|
||||
}
|
||||
|
||||
DomainShader::DomainShader()
|
||||
{
|
||||
}
|
||||
DomainShader::~DomainShader()
|
||||
{
|
||||
if (device != nullptr)
|
||||
@@ -47,9 +35,6 @@ namespace wiGraphicsTypes
|
||||
}
|
||||
}
|
||||
|
||||
HullShader::HullShader()
|
||||
{
|
||||
}
|
||||
HullShader::~HullShader()
|
||||
{
|
||||
if (device != nullptr)
|
||||
@@ -58,9 +43,6 @@ namespace wiGraphicsTypes
|
||||
}
|
||||
}
|
||||
|
||||
ComputeShader::ComputeShader()
|
||||
{
|
||||
}
|
||||
ComputeShader::~ComputeShader()
|
||||
{
|
||||
if (device != nullptr)
|
||||
@@ -69,9 +51,6 @@ namespace wiGraphicsTypes
|
||||
}
|
||||
}
|
||||
|
||||
Sampler::Sampler()
|
||||
{
|
||||
}
|
||||
Sampler::~Sampler()
|
||||
{
|
||||
if (device != nullptr)
|
||||
@@ -80,9 +59,6 @@ namespace wiGraphicsTypes
|
||||
}
|
||||
}
|
||||
|
||||
GPUResource::GPUResource()
|
||||
{
|
||||
}
|
||||
GPUResource::~GPUResource()
|
||||
{
|
||||
if (device != nullptr)
|
||||
@@ -91,9 +67,6 @@ namespace wiGraphicsTypes
|
||||
}
|
||||
}
|
||||
|
||||
GPUBuffer::GPUBuffer() : GPUResource()
|
||||
{
|
||||
}
|
||||
GPUBuffer::~GPUBuffer()
|
||||
{
|
||||
if (device != nullptr)
|
||||
@@ -102,9 +75,6 @@ namespace wiGraphicsTypes
|
||||
}
|
||||
}
|
||||
|
||||
VertexLayout::VertexLayout()
|
||||
{
|
||||
}
|
||||
VertexLayout::~VertexLayout()
|
||||
{
|
||||
if (device != nullptr)
|
||||
@@ -113,9 +83,6 @@ namespace wiGraphicsTypes
|
||||
}
|
||||
}
|
||||
|
||||
BlendState::BlendState()
|
||||
{
|
||||
}
|
||||
BlendState::~BlendState()
|
||||
{
|
||||
if (device != nullptr)
|
||||
@@ -124,9 +91,6 @@ namespace wiGraphicsTypes
|
||||
}
|
||||
}
|
||||
|
||||
DepthStencilState::DepthStencilState()
|
||||
{
|
||||
}
|
||||
DepthStencilState::~DepthStencilState()
|
||||
{
|
||||
if (device != nullptr)
|
||||
@@ -135,9 +99,6 @@ namespace wiGraphicsTypes
|
||||
}
|
||||
}
|
||||
|
||||
RasterizerState::RasterizerState()
|
||||
{
|
||||
}
|
||||
RasterizerState::~RasterizerState()
|
||||
{
|
||||
if (device != nullptr)
|
||||
@@ -146,12 +107,6 @@ namespace wiGraphicsTypes
|
||||
}
|
||||
}
|
||||
|
||||
Texture::Texture() : GPUResource()
|
||||
{
|
||||
}
|
||||
Texture::~Texture()
|
||||
{
|
||||
}
|
||||
void Texture::RequestIndependentRenderTargetArraySlices(bool value)
|
||||
{
|
||||
independentRTVArraySlices = value;
|
||||
@@ -173,9 +128,6 @@ namespace wiGraphicsTypes
|
||||
independentUAVMIPs = value;
|
||||
}
|
||||
|
||||
Texture1D::Texture1D() :Texture()
|
||||
{
|
||||
}
|
||||
Texture1D::~Texture1D()
|
||||
{
|
||||
if (device != nullptr)
|
||||
@@ -184,9 +136,6 @@ namespace wiGraphicsTypes
|
||||
}
|
||||
}
|
||||
|
||||
Texture2D::Texture2D() :Texture()
|
||||
{
|
||||
}
|
||||
Texture2D::~Texture2D()
|
||||
{
|
||||
if (device != nullptr)
|
||||
@@ -195,9 +144,6 @@ namespace wiGraphicsTypes
|
||||
}
|
||||
}
|
||||
|
||||
Texture3D::Texture3D() :Texture()
|
||||
{
|
||||
}
|
||||
Texture3D::~Texture3D()
|
||||
{
|
||||
if (device != nullptr)
|
||||
@@ -206,9 +152,6 @@ namespace wiGraphicsTypes
|
||||
}
|
||||
}
|
||||
|
||||
GPUQuery::GPUQuery()
|
||||
{
|
||||
}
|
||||
GPUQuery::~GPUQuery()
|
||||
{
|
||||
if (device != nullptr)
|
||||
@@ -218,9 +161,6 @@ namespace wiGraphicsTypes
|
||||
}
|
||||
|
||||
|
||||
GraphicsPSO::GraphicsPSO()
|
||||
{
|
||||
}
|
||||
GraphicsPSO::~GraphicsPSO()
|
||||
{
|
||||
if (device != nullptr)
|
||||
@@ -229,9 +169,6 @@ namespace wiGraphicsTypes
|
||||
}
|
||||
}
|
||||
|
||||
ComputePSO::ComputePSO()
|
||||
{
|
||||
}
|
||||
ComputePSO::~ComputePSO()
|
||||
{
|
||||
if (device != nullptr)
|
||||
|
||||
@@ -29,7 +29,6 @@ namespace wiGraphicsTypes
|
||||
|
||||
struct VertexShader : public GraphicsDeviceChild
|
||||
{
|
||||
VertexShader();
|
||||
~VertexShader();
|
||||
|
||||
ShaderByteCode code;
|
||||
@@ -38,7 +37,6 @@ namespace wiGraphicsTypes
|
||||
|
||||
struct PixelShader : public GraphicsDeviceChild
|
||||
{
|
||||
PixelShader();
|
||||
~PixelShader();
|
||||
|
||||
ShaderByteCode code;
|
||||
@@ -47,7 +45,6 @@ namespace wiGraphicsTypes
|
||||
|
||||
struct GeometryShader : public GraphicsDeviceChild
|
||||
{
|
||||
GeometryShader();
|
||||
~GeometryShader();
|
||||
|
||||
ShaderByteCode code;
|
||||
@@ -56,7 +53,6 @@ namespace wiGraphicsTypes
|
||||
|
||||
struct HullShader : public GraphicsDeviceChild
|
||||
{
|
||||
HullShader();
|
||||
~HullShader();
|
||||
|
||||
ShaderByteCode code;
|
||||
@@ -65,7 +61,6 @@ namespace wiGraphicsTypes
|
||||
|
||||
struct DomainShader : public GraphicsDeviceChild
|
||||
{
|
||||
DomainShader();
|
||||
~DomainShader();
|
||||
|
||||
ShaderByteCode code;
|
||||
@@ -74,7 +69,6 @@ namespace wiGraphicsTypes
|
||||
|
||||
struct ComputeShader : public GraphicsDeviceChild
|
||||
{
|
||||
ComputeShader();
|
||||
~ComputeShader();
|
||||
|
||||
ShaderByteCode code;
|
||||
@@ -86,7 +80,6 @@ namespace wiGraphicsTypes
|
||||
wiCPUHandle resource = WI_NULL_HANDLE;
|
||||
SamplerDesc desc;
|
||||
|
||||
Sampler();
|
||||
~Sampler();
|
||||
|
||||
const SamplerDesc& GetDesc() const { return desc; }
|
||||
@@ -114,7 +107,6 @@ namespace wiGraphicsTypes
|
||||
wiCPUHandle resource = WI_NULL_HANDLE;
|
||||
wiCPUHandle resourceMemory = WI_NULL_HANDLE;
|
||||
|
||||
GPUResource();
|
||||
virtual ~GPUResource();
|
||||
};
|
||||
|
||||
@@ -123,7 +115,6 @@ namespace wiGraphicsTypes
|
||||
wiCPUHandle CBV = WI_NULL_HANDLE;
|
||||
GPUBufferDesc desc;
|
||||
|
||||
GPUBuffer();
|
||||
virtual ~GPUBuffer();
|
||||
|
||||
const GPUBufferDesc& GetDesc() const { return desc; }
|
||||
@@ -135,7 +126,6 @@ namespace wiGraphicsTypes
|
||||
|
||||
std::vector<VertexLayoutDesc> desc;
|
||||
|
||||
VertexLayout();
|
||||
~VertexLayout();
|
||||
};
|
||||
|
||||
@@ -144,7 +134,6 @@ namespace wiGraphicsTypes
|
||||
wiCPUHandle resource = WI_NULL_HANDLE;
|
||||
BlendStateDesc desc;
|
||||
|
||||
BlendState();
|
||||
~BlendState();
|
||||
|
||||
const BlendStateDesc& GetDesc() const { return desc; }
|
||||
@@ -155,7 +144,6 @@ namespace wiGraphicsTypes
|
||||
wiCPUHandle resource = WI_NULL_HANDLE;
|
||||
DepthStencilStateDesc desc;
|
||||
|
||||
DepthStencilState();
|
||||
~DepthStencilState();
|
||||
|
||||
const DepthStencilStateDesc& GetDesc() const { return desc; }
|
||||
@@ -166,7 +154,6 @@ namespace wiGraphicsTypes
|
||||
wiCPUHandle resource = WI_NULL_HANDLE;
|
||||
RasterizerStateDesc desc;
|
||||
|
||||
RasterizerState();
|
||||
~RasterizerState();
|
||||
|
||||
const RasterizerStateDesc& GetDesc() const { return desc; }
|
||||
@@ -185,9 +172,6 @@ namespace wiGraphicsTypes
|
||||
|
||||
const TextureDesc& GetDesc() const { return desc; }
|
||||
|
||||
Texture();
|
||||
virtual ~Texture();
|
||||
|
||||
// if true, then each array slice will get a unique rendertarget
|
||||
void RequestIndependentRenderTargetArraySlices(bool value);
|
||||
// if true, then each face of the cubemap will get a unique rendertarget
|
||||
@@ -202,7 +186,6 @@ namespace wiGraphicsTypes
|
||||
|
||||
struct Texture1D : public Texture
|
||||
{
|
||||
Texture1D();
|
||||
virtual ~Texture1D();
|
||||
};
|
||||
|
||||
@@ -211,13 +194,11 @@ namespace wiGraphicsTypes
|
||||
wiCPUHandle DSV = WI_NULL_HANDLE;
|
||||
std::vector<wiCPUHandle> additionalDSVs;
|
||||
|
||||
Texture2D();
|
||||
virtual ~Texture2D();
|
||||
};
|
||||
|
||||
struct Texture3D : public Texture
|
||||
{
|
||||
Texture3D();
|
||||
virtual ~Texture3D();
|
||||
};
|
||||
|
||||
@@ -229,8 +210,7 @@ namespace wiGraphicsTypes
|
||||
wiCPUHandle resource = WI_NULL_HANDLE;
|
||||
GPUQueryDesc desc;
|
||||
|
||||
GPUQuery();
|
||||
virtual ~GPUQuery();
|
||||
~GPUQuery();
|
||||
|
||||
const GPUQueryDesc& GetDesc() const { return desc; }
|
||||
};
|
||||
@@ -243,7 +223,6 @@ namespace wiGraphicsTypes
|
||||
|
||||
const GraphicsPSODesc& GetDesc() const { return desc; }
|
||||
|
||||
GraphicsPSO();
|
||||
~GraphicsPSO();
|
||||
};
|
||||
struct ComputePSO : public GraphicsDeviceChild
|
||||
@@ -253,7 +232,6 @@ namespace wiGraphicsTypes
|
||||
|
||||
const ComputePSODesc& GetDesc() const { return desc; }
|
||||
|
||||
ComputePSO();
|
||||
~ComputePSO();
|
||||
};
|
||||
|
||||
|
||||
+77
-110
@@ -4,49 +4,15 @@
|
||||
|
||||
using namespace wiGraphicsTypes;
|
||||
|
||||
|
||||
wiRenderTarget::wiRenderTarget()
|
||||
{
|
||||
numViews = 0;
|
||||
depth = nullptr;
|
||||
}
|
||||
wiRenderTarget::wiRenderTarget(UINT width, UINT height, bool hasDepth, FORMAT format, UINT mipMapLevelCount, UINT MSAAC, bool depthOnly)
|
||||
{
|
||||
numViews = 0;
|
||||
depth = nullptr;
|
||||
Initialize(width, height, hasDepth, format, mipMapLevelCount, MSAAC);
|
||||
}
|
||||
|
||||
|
||||
wiRenderTarget::~wiRenderTarget()
|
||||
{
|
||||
CleanUp();
|
||||
}
|
||||
|
||||
void wiRenderTarget::CleanUp() {
|
||||
for (size_t i = 0; i < renderTargets.size(); ++i)
|
||||
{
|
||||
SAFE_DELETE(renderTargets[i]);
|
||||
}
|
||||
for (size_t i = 0; i < renderTargets_resolvedMSAA.size(); ++i)
|
||||
{
|
||||
SAFE_DELETE(renderTargets_resolvedMSAA[i]);
|
||||
}
|
||||
renderTargets.clear();
|
||||
renderTargets_resolvedMSAA.clear();
|
||||
SAFE_DELETE(depth);
|
||||
resolvedMSAAUptodate.clear();
|
||||
}
|
||||
|
||||
void wiRenderTarget::Initialize(UINT width, UINT height, bool hasDepth
|
||||
, FORMAT format, UINT mipMapLevelCount, UINT MSAAC, bool depthOnly)
|
||||
{
|
||||
CleanUp();
|
||||
slots.clear();
|
||||
slots.reserve(8); // graphics types cannot be moved!
|
||||
|
||||
if (!depthOnly)
|
||||
{
|
||||
TextureDesc textureDesc;
|
||||
ZeroMemory(&textureDesc, sizeof(textureDesc));
|
||||
textureDesc.Width = width;
|
||||
textureDesc.Height = height;
|
||||
textureDesc.MipLevels = mipMapLevelCount;
|
||||
@@ -59,49 +25,43 @@ void wiRenderTarget::Initialize(UINT width, UINT height, bool hasDepth
|
||||
textureDesc.CPUAccessFlags = 0;
|
||||
textureDesc.MiscFlags = 0;
|
||||
|
||||
numViews = 1;
|
||||
Texture2D* texture = new Texture2D;
|
||||
slots.emplace_back();
|
||||
|
||||
if (mipMapLevelCount != 1)
|
||||
{
|
||||
texture->RequestIndependentShaderResourcesForMIPs(true);
|
||||
texture->RequestIndependentUnorderedAccessResourcesForMIPs(true);
|
||||
slots.back().target_primary.RequestIndependentShaderResourcesForMIPs(true);
|
||||
slots.back().target_primary.RequestIndependentUnorderedAccessResourcesForMIPs(true);
|
||||
textureDesc.BindFlags |= BIND_UNORDERED_ACCESS;
|
||||
}
|
||||
renderTargets.push_back(texture);
|
||||
wiRenderer::GetDevice()->CreateTexture2D(&textureDesc, nullptr, renderTargets[0]);
|
||||
wiRenderer::GetDevice()->CreateTexture2D(&textureDesc, nullptr, &slots.back().target_primary);
|
||||
if (MSAAC > 1)
|
||||
{
|
||||
textureDesc.SampleDesc.Count = 1;
|
||||
renderTargets_resolvedMSAA.push_back(new Texture2D);
|
||||
wiRenderer::GetDevice()->CreateTexture2D(&textureDesc, nullptr, renderTargets_resolvedMSAA[0]);
|
||||
resolvedMSAAUptodate.push_back(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
resolvedMSAAUptodate.push_back(true);
|
||||
wiRenderer::GetDevice()->CreateTexture2D(&textureDesc, nullptr, &slots.back().target_resolved);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
viewPort.Width = (FLOAT)width;
|
||||
viewPort.Height = (FLOAT)height;
|
||||
viewPort.MinDepth = 0.0f;
|
||||
viewPort.MaxDepth = 1.0f;
|
||||
viewPort.TopLeftX = 0;
|
||||
viewPort.TopLeftY = 0;
|
||||
viewPort.MinDepth = 0.0f;
|
||||
viewPort.MaxDepth = 1.0f;
|
||||
viewPort.TopLeftX = 0;
|
||||
viewPort.TopLeftY = 0;
|
||||
|
||||
if(hasDepth) {
|
||||
depth = new wiDepthTarget();
|
||||
depth->Initialize(width,height,MSAAC);
|
||||
if (hasDepth)
|
||||
{
|
||||
depth.reset(new wiDepthTarget);
|
||||
depth->Initialize(width, height, MSAAC);
|
||||
}
|
||||
}
|
||||
void wiRenderTarget::InitializeCube(UINT size, bool hasDepth, FORMAT format, UINT mipMapLevelCount, bool depthOnly)
|
||||
{
|
||||
CleanUp();
|
||||
slots.clear();
|
||||
slots.reserve(8); // graphics types cannot be moved!
|
||||
|
||||
if (!depthOnly)
|
||||
{
|
||||
TextureDesc textureDesc;
|
||||
ZeroMemory(&textureDesc, sizeof(textureDesc));
|
||||
textureDesc.Width = size;
|
||||
textureDesc.Height = size;
|
||||
textureDesc.MipLevels = mipMapLevelCount;
|
||||
@@ -114,58 +74,50 @@ void wiRenderTarget::InitializeCube(UINT size, bool hasDepth, FORMAT format, UIN
|
||||
textureDesc.CPUAccessFlags = 0;
|
||||
textureDesc.MiscFlags = RESOURCE_MISC_TEXTURECUBE;
|
||||
|
||||
Texture2D* texture = new Texture2D;
|
||||
slots.emplace_back();
|
||||
|
||||
if (mipMapLevelCount != 1)
|
||||
{
|
||||
texture->RequestIndependentShaderResourcesForMIPs(true);
|
||||
texture->RequestIndependentUnorderedAccessResourcesForMIPs(true);
|
||||
slots.back().target_primary.RequestIndependentShaderResourcesForMIPs(true);
|
||||
slots.back().target_primary.RequestIndependentUnorderedAccessResourcesForMIPs(true);
|
||||
textureDesc.BindFlags |= BIND_UNORDERED_ACCESS;
|
||||
//textureDesc.MiscFlags |= RESOURCE_MISC_GENERATE_MIPS;
|
||||
}
|
||||
|
||||
numViews = 1;
|
||||
renderTargets.push_back(texture);
|
||||
wiRenderer::GetDevice()->CreateTexture2D(&textureDesc, nullptr, renderTargets[0]);
|
||||
resolvedMSAAUptodate.push_back(true);
|
||||
wiRenderer::GetDevice()->CreateTexture2D(&textureDesc, nullptr, &slots.back().target_primary);
|
||||
}
|
||||
|
||||
|
||||
viewPort.Width = (FLOAT)size;
|
||||
viewPort.Height = (FLOAT)size;
|
||||
viewPort.MinDepth = 0.0f;
|
||||
viewPort.MaxDepth = 1.0f;
|
||||
viewPort.TopLeftX = 0;
|
||||
viewPort.TopLeftY = 0;
|
||||
viewPort.MinDepth = 0.0f;
|
||||
viewPort.MaxDepth = 1.0f;
|
||||
viewPort.TopLeftX = 0;
|
||||
viewPort.TopLeftY = 0;
|
||||
|
||||
if(hasDepth) {
|
||||
depth = new wiDepthTarget();
|
||||
if (hasDepth)
|
||||
{
|
||||
depth.reset(new wiDepthTarget);
|
||||
depth->InitializeCube(size);
|
||||
}
|
||||
}
|
||||
void wiRenderTarget::Add(FORMAT format)
|
||||
{
|
||||
TextureDesc desc = GetTexture(0)->GetDesc();
|
||||
TextureDesc desc = GetTexture(0).GetDesc();
|
||||
desc.Format = format;
|
||||
|
||||
if (!renderTargets.empty())
|
||||
if (!slots.empty())
|
||||
{
|
||||
numViews++;
|
||||
renderTargets.push_back(new Texture2D);
|
||||
wiRenderer::GetDevice()->CreateTexture2D(&desc, nullptr, renderTargets.back());
|
||||
slots.emplace_back();
|
||||
|
||||
wiRenderer::GetDevice()->CreateTexture2D(&desc, nullptr, &slots.back().target_primary);
|
||||
if (desc.SampleDesc.Count > 1)
|
||||
{
|
||||
desc.SampleDesc.Count = 1;
|
||||
renderTargets_resolvedMSAA.push_back(new Texture2D);
|
||||
wiRenderer::GetDevice()->CreateTexture2D(&desc, nullptr, renderTargets_resolvedMSAA.back());
|
||||
resolvedMSAAUptodate.push_back(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
resolvedMSAAUptodate.push_back(true);
|
||||
wiRenderer::GetDevice()->CreateTexture2D(&desc, nullptr, &slots.back().target_resolved);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0 && "Rendertarget Add failed because it is not properly initilaized!");
|
||||
assert(0 && "Rendertarget Add failed because it is not properly initialized!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -182,15 +134,20 @@ void wiRenderTarget::SetAndClear(GRAPHICSTHREAD threadID, float r, float g, floa
|
||||
float ClearColor[4] = { r, g, b, a };
|
||||
if (viewID >= 0)
|
||||
{
|
||||
wiRenderer::GetDevice()->ClearRenderTarget(GetTexture(viewID), ClearColor, threadID);
|
||||
wiRenderer::GetDevice()->ClearRenderTarget(&GetTexture(viewID), ClearColor, threadID);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < numViews; ++i)
|
||||
wiRenderer::GetDevice()->ClearRenderTarget(GetTexture(i), ClearColor, threadID);
|
||||
for (int i = 0; i < (int)slots.size(); ++i)
|
||||
{
|
||||
wiRenderer::GetDevice()->ClearRenderTarget(&GetTexture(i), ClearColor, threadID);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(depth) depth->Clear(threadID);
|
||||
if (depth)
|
||||
{
|
||||
depth->Clear(threadID);
|
||||
}
|
||||
}
|
||||
void wiRenderTarget::SetAndClear(GRAPHICSTHREAD threadID, wiDepthTarget* getDepth, float r, float g, float b, float a, bool disableColor, int viewID)
|
||||
{
|
||||
@@ -200,12 +157,14 @@ void wiRenderTarget::SetAndClear(GRAPHICSTHREAD threadID, wiDepthTarget* getDept
|
||||
float ClearColor[4] = { r, g, b, a };
|
||||
if (viewID >= 0)
|
||||
{
|
||||
wiRenderer::GetDevice()->ClearRenderTarget(GetTexture(viewID), ClearColor, threadID);
|
||||
wiRenderer::GetDevice()->ClearRenderTarget(&GetTexture(viewID), ClearColor, threadID);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < numViews; ++i)
|
||||
wiRenderer::GetDevice()->ClearRenderTarget(GetTexture(i), ClearColor, threadID);
|
||||
for (int i = 0; i < (int)slots.size(); ++i)
|
||||
{
|
||||
wiRenderer::GetDevice()->ClearRenderTarget(&GetTexture(i), ClearColor, threadID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -220,52 +179,60 @@ void wiRenderTarget::Deactivate(GRAPHICSTHREAD threadID)
|
||||
void wiRenderTarget::Set(GRAPHICSTHREAD threadID, bool disableColor, int viewID)
|
||||
{
|
||||
wiRenderer::GetDevice()->BindViewports(1, &viewPort, threadID);
|
||||
|
||||
const Texture2D* rts[8];
|
||||
if (viewID >= 0)
|
||||
{
|
||||
wiRenderer::GetDevice()->BindRenderTargets(disableColor ? 0 : 1, disableColor ? nullptr : (Texture2D**)&renderTargets[viewID], (depth ? depth->GetTexture() : nullptr), threadID);
|
||||
resolvedMSAAUptodate[viewID] = false;
|
||||
rts[0] = &slots[viewID].target_primary;
|
||||
wiRenderer::GetDevice()->BindRenderTargets(disableColor ? 0 : 1, disableColor ? nullptr : rts, (depth ? &depth->GetTexture() : nullptr), threadID);
|
||||
slots[viewID].dirty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
wiRenderer::GetDevice()->BindRenderTargets(disableColor ? 0 : numViews, disableColor ? nullptr : (Texture2D**)renderTargets.data(), (depth ? depth->GetTexture() : nullptr), threadID);
|
||||
for (auto& x : resolvedMSAAUptodate)
|
||||
for (int i = 0; i < (int)slots.size(); ++i)
|
||||
{
|
||||
x = false;
|
||||
slots[i].dirty = true;
|
||||
rts[i] = &slots[i].target_primary;
|
||||
}
|
||||
wiRenderer::GetDevice()->BindRenderTargets(disableColor ? 0 : (UINT)slots.size(), disableColor ? nullptr : rts, (depth ? &depth->GetTexture() : nullptr), threadID);
|
||||
}
|
||||
}
|
||||
void wiRenderTarget::Set(GRAPHICSTHREAD threadID, wiDepthTarget* getDepth, bool disableColor, int viewID)
|
||||
{
|
||||
wiRenderer::GetDevice()->BindViewports(1, &viewPort, threadID);
|
||||
|
||||
const Texture2D* rts[8];
|
||||
if (viewID >= 0)
|
||||
{
|
||||
wiRenderer::GetDevice()->BindRenderTargets(disableColor ? 0 : 1, disableColor ? nullptr : (Texture2D**)&renderTargets[viewID], (getDepth ? getDepth->GetTexture() : nullptr), threadID);
|
||||
resolvedMSAAUptodate[viewID] = false;
|
||||
rts[0] = &slots[viewID].target_primary;
|
||||
wiRenderer::GetDevice()->BindRenderTargets(disableColor ? 0 : 1, disableColor ? nullptr : rts, (getDepth ? &getDepth->GetTexture() : nullptr), threadID);
|
||||
slots[viewID].dirty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
wiRenderer::GetDevice()->BindRenderTargets(disableColor ? 0 : numViews, disableColor ? nullptr : (Texture2D**)renderTargets.data(), (getDepth ? getDepth->GetTexture() : nullptr), threadID);
|
||||
for (auto& x : resolvedMSAAUptodate)
|
||||
for (int i = 0; i < (int)slots.size(); ++i)
|
||||
{
|
||||
x = false;
|
||||
slots[i].dirty = true;
|
||||
rts[i] = &slots[i].target_primary;
|
||||
}
|
||||
wiRenderer::GetDevice()->BindRenderTargets(disableColor ? 0 : (UINT)slots.size(), disableColor ? nullptr : rts, (getDepth ? &getDepth->GetTexture() : nullptr), threadID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Texture2D* wiRenderTarget::GetTextureResolvedMSAA(GRAPHICSTHREAD threadID, int viewID)
|
||||
const Texture2D& wiRenderTarget::GetTextureResolvedMSAA(GRAPHICSTHREAD threadID, int viewID)
|
||||
{
|
||||
if (GetDesc(viewID).SampleDesc.Count > 1)
|
||||
{
|
||||
if (resolvedMSAAUptodate[viewID] == false)
|
||||
if (slots[viewID].dirty)
|
||||
{
|
||||
wiRenderer::GetDevice()->MSAAResolve(renderTargets_resolvedMSAA[viewID], renderTargets[viewID], threadID);
|
||||
resolvedMSAAUptodate[viewID] = true;
|
||||
wiRenderer::GetDevice()->MSAAResolve(&slots[viewID].target_resolved, &slots[viewID].target_primary, threadID);
|
||||
slots[viewID].dirty = false;
|
||||
}
|
||||
return renderTargets_resolvedMSAA[viewID];
|
||||
return slots[viewID].target_resolved;
|
||||
}
|
||||
|
||||
return renderTargets[viewID];
|
||||
return slots[viewID].target_primary;
|
||||
}
|
||||
UINT wiRenderTarget::GetMipCount()
|
||||
{
|
||||
|
||||
@@ -3,24 +3,23 @@
|
||||
#include "wiGraphicsDevice.h"
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
class wiDepthTarget;
|
||||
|
||||
class wiRenderTarget
|
||||
{
|
||||
private:
|
||||
int numViews;
|
||||
std::vector<wiGraphicsTypes::Texture2D*> renderTargets;
|
||||
std::vector<wiGraphicsTypes::Texture2D*> renderTargets_resolvedMSAA;
|
||||
std::vector<int> resolvedMSAAUptodate;
|
||||
struct RenderTargetSlot
|
||||
{
|
||||
wiGraphicsTypes::Texture2D target_primary;
|
||||
wiGraphicsTypes::Texture2D target_resolved;
|
||||
bool dirty = true;
|
||||
};
|
||||
std::vector<RenderTargetSlot> slots;
|
||||
public:
|
||||
wiGraphicsTypes::ViewPort viewPort;
|
||||
wiDepthTarget* depth;
|
||||
|
||||
wiRenderTarget();
|
||||
wiRenderTarget(UINT width, UINT height, bool hasDepth = false, wiGraphicsTypes::FORMAT format = wiGraphicsTypes::FORMAT_R8G8B8A8_UNORM, UINT mipMapLevelCount = 1, UINT MSAAC = 1, bool depthOnly = false);
|
||||
~wiRenderTarget();
|
||||
void CleanUp();
|
||||
wiGraphicsTypes::ViewPort viewPort;
|
||||
std::unique_ptr<wiDepthTarget> depth;
|
||||
|
||||
void Initialize(UINT width, UINT height, bool hasDepth = false, wiGraphicsTypes::FORMAT format = wiGraphicsTypes::FORMAT_R8G8B8A8_UNORM, UINT mipMapLevelCount = 1, UINT MSAAC = 1, bool depthOnly = false);
|
||||
void InitializeCube(UINT size, bool hasDepth, wiGraphicsTypes::FORMAT format = wiGraphicsTypes::FORMAT_R8G8B8A8_UNORM, UINT mipMapLevelCount = 1, bool depthOnly = false);
|
||||
@@ -33,10 +32,10 @@ public:
|
||||
void Set(GRAPHICSTHREAD threadID, bool disableColor = false, int viewID = -1);
|
||||
void Set(GRAPHICSTHREAD threadID, wiDepthTarget*, bool disableColor = false, int viewID = -1);
|
||||
|
||||
wiGraphicsTypes::Texture2D* GetTexture(int viewID = 0) const { return renderTargets[viewID]; }
|
||||
wiGraphicsTypes::Texture2D* GetTextureResolvedMSAA(GRAPHICSTHREAD threadID, int viewID = 0);
|
||||
wiGraphicsTypes::TextureDesc GetDesc(int viewID = 0) const { assert(viewID < numViews); return GetTexture(viewID)->GetDesc(); }
|
||||
const wiGraphicsTypes::Texture2D& GetTexture(int viewID = 0) const { return slots[viewID].target_primary; }
|
||||
const wiGraphicsTypes::Texture2D& GetTextureResolvedMSAA(GRAPHICSTHREAD threadID, int viewID = 0);
|
||||
wiGraphicsTypes::TextureDesc GetDesc(int viewID = 0) const { return GetTexture(viewID).GetDesc(); }
|
||||
UINT GetMipCount();
|
||||
bool IsInitialized() const { return (numViews > 0 || depth != nullptr); }
|
||||
bool IsInitialized() const { return (!slots.empty() || depth != nullptr); }
|
||||
};
|
||||
|
||||
|
||||
+33
-36
@@ -32,6 +32,7 @@
|
||||
#include "wiJobSystem.h"
|
||||
#include "wiSpinLock.h"
|
||||
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
#include <unordered_set>
|
||||
#include <deque>
|
||||
@@ -47,7 +48,7 @@ using namespace wiAllocators;
|
||||
namespace wiRenderer
|
||||
{
|
||||
|
||||
GraphicsDevice* graphicsDevice = nullptr;
|
||||
GraphicsDevice* graphicsDevice = nullptr;
|
||||
|
||||
const VertexShader* vertexShaders[VSTYPE_LAST] = {};
|
||||
const PixelShader* pixelShaders[PSTYPE_LAST] = {};
|
||||
@@ -134,11 +135,11 @@ struct VoxelizedSceneData
|
||||
UINT mips = 7;
|
||||
} voxelSceneData;
|
||||
|
||||
wiOcean* ocean = nullptr;
|
||||
std::unique_ptr<wiOcean> ocean;
|
||||
|
||||
std::unique_ptr<Texture2D> shadowMapArray_2D;
|
||||
std::unique_ptr<Texture2D> shadowMapArray_Cube;
|
||||
std::unique_ptr<Texture2D> shadowMapArray_Transparent;
|
||||
Texture2D shadowMapArray_2D;
|
||||
Texture2D shadowMapArray_Cube;
|
||||
Texture2D shadowMapArray_Transparent;
|
||||
|
||||
deque<wiSprite*> waterRipples;
|
||||
|
||||
@@ -165,7 +166,7 @@ unordered_map<const Texture2D*, wiRectPacker::rect_xywh> packedLightmaps;
|
||||
|
||||
|
||||
|
||||
void SetDevice(wiGraphicsTypes::GraphicsDevice* newDevice)
|
||||
void SetDevice(GraphicsDevice* newDevice)
|
||||
{
|
||||
graphicsDevice = newDevice;
|
||||
}
|
||||
@@ -4748,11 +4749,8 @@ void SetShadowProps2D(int resolution, int count, int softShadowQuality)
|
||||
|
||||
if (SHADOWCOUNT_2D > 0 && SHADOWRES_2D > 0)
|
||||
{
|
||||
shadowMapArray_2D.reset(new Texture2D);
|
||||
shadowMapArray_2D->RequestIndependentRenderTargetArraySlices(true);
|
||||
|
||||
shadowMapArray_Transparent.reset(new Texture2D);
|
||||
shadowMapArray_Transparent->RequestIndependentRenderTargetArraySlices(true);
|
||||
shadowMapArray_2D.RequestIndependentRenderTargetArraySlices(true);
|
||||
shadowMapArray_Transparent.RequestIndependentRenderTargetArraySlices(true);
|
||||
|
||||
TextureDesc desc;
|
||||
desc.Width = SHADOWRES_2D;
|
||||
@@ -4767,11 +4765,11 @@ void SetShadowProps2D(int resolution, int count, int softShadowQuality)
|
||||
|
||||
desc.BindFlags = BIND_DEPTH_STENCIL | BIND_SHADER_RESOURCE;
|
||||
desc.Format = DSFormat_small_alias;
|
||||
GetDevice()->CreateTexture2D(&desc, nullptr, shadowMapArray_2D.get());
|
||||
GetDevice()->CreateTexture2D(&desc, nullptr, &shadowMapArray_2D);
|
||||
|
||||
desc.BindFlags = BIND_RENDER_TARGET | BIND_SHADER_RESOURCE;
|
||||
desc.Format = RTFormat_ldr;
|
||||
GetDevice()->CreateTexture2D(&desc, nullptr, shadowMapArray_Transparent.get());
|
||||
GetDevice()->CreateTexture2D(&desc, nullptr, &shadowMapArray_Transparent);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4788,9 +4786,8 @@ void SetShadowPropsCube(int resolution, int count)
|
||||
|
||||
if (SHADOWCOUNT_CUBE > 0 && SHADOWRES_CUBE > 0)
|
||||
{
|
||||
shadowMapArray_Cube.reset(new Texture2D);
|
||||
shadowMapArray_Cube->RequestIndependentRenderTargetArraySlices(true);
|
||||
shadowMapArray_Cube->RequestIndependentRenderTargetCubemapFaces(false);
|
||||
shadowMapArray_Cube.RequestIndependentRenderTargetArraySlices(true);
|
||||
shadowMapArray_Cube.RequestIndependentRenderTargetCubemapFaces(false);
|
||||
|
||||
TextureDesc desc;
|
||||
desc.Width = SHADOWRES_CUBE;
|
||||
@@ -4804,7 +4801,7 @@ void SetShadowPropsCube(int resolution, int count)
|
||||
desc.BindFlags = BIND_DEPTH_STENCIL | BIND_SHADER_RESOURCE;
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.MiscFlags = RESOURCE_MISC_TEXTURECUBE;
|
||||
GetDevice()->CreateTexture2D(&desc, nullptr, shadowMapArray_Cube.get());
|
||||
GetDevice()->CreateTexture2D(&desc, nullptr, &shadowMapArray_Cube);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4939,22 +4936,22 @@ void DrawForShadowMap(const CameraComponent& camera, GRAPHICSTHREAD threadID, ui
|
||||
XMStoreFloat4x4(&cb.g_xCamera_VP, shcams[cascade].getVP());
|
||||
device->UpdateBuffer(&constantBuffers[CBTYPE_CAMERA], &cb, threadID);
|
||||
|
||||
device->ClearDepthStencil(shadowMapArray_2D.get(), CLEAR_DEPTH, 0.0f, 0, threadID, light.shadowMap_index + cascade);
|
||||
device->ClearDepthStencil(&shadowMapArray_2D, CLEAR_DEPTH, 0.0f, 0, threadID, light.shadowMap_index + cascade);
|
||||
|
||||
// unfortunately we will always have to clear the associated transparent shadowmap to avoid discrepancy with shadowmap indexing changes across frames
|
||||
device->ClearRenderTarget(shadowMapArray_Transparent.get(), transparentShadowClearColor, threadID, light.shadowMap_index + cascade);
|
||||
device->ClearRenderTarget(&shadowMapArray_Transparent, transparentShadowClearColor, threadID, light.shadowMap_index + cascade);
|
||||
|
||||
// render opaque shadowmap:
|
||||
device->BindRenderTargets(0, nullptr, shadowMapArray_2D.get(), threadID, light.shadowMap_index + cascade);
|
||||
device->BindRenderTargets(0, nullptr, &shadowMapArray_2D, threadID, light.shadowMap_index + cascade);
|
||||
RenderMeshes(renderQueue, RENDERPASS_SHADOW, RENDERTYPE_OPAQUE, threadID);
|
||||
|
||||
if (GetTransparentShadowsEnabled() && transparentShadowsRequested)
|
||||
{
|
||||
// render transparent shadowmap:
|
||||
Texture2D* rts[] = {
|
||||
shadowMapArray_Transparent.get()
|
||||
const Texture2D* rts[] = {
|
||||
&shadowMapArray_Transparent
|
||||
};
|
||||
device->BindRenderTargets(ARRAYSIZE(rts), rts, shadowMapArray_2D.get(), threadID, light.shadowMap_index + cascade);
|
||||
device->BindRenderTargets(ARRAYSIZE(rts), rts, &shadowMapArray_2D, threadID, light.shadowMap_index + cascade);
|
||||
RenderMeshes(renderQueue, RENDERPASS_SHADOW, RENDERTYPE_TRANSPARENT | RENDERTYPE_WATER, threadID);
|
||||
}
|
||||
frameAllocators[threadID].free(sizeof(RenderBatch) * renderQueue.batchCount);
|
||||
@@ -5013,22 +5010,22 @@ void DrawForShadowMap(const CameraComponent& camera, GRAPHICSTHREAD threadID, ui
|
||||
XMStoreFloat4x4(&cb.g_xCamera_VP, shcam.getVP());
|
||||
device->UpdateBuffer(&constantBuffers[CBTYPE_CAMERA], &cb, threadID);
|
||||
|
||||
device->ClearDepthStencil(shadowMapArray_2D.get(), CLEAR_DEPTH, 0.0f, 0, threadID, light.shadowMap_index);
|
||||
device->ClearDepthStencil(&shadowMapArray_2D, CLEAR_DEPTH, 0.0f, 0, threadID, light.shadowMap_index);
|
||||
|
||||
// unfortunately we will always have to clear the associated transparent shadowmap to avoid discrepancy with shadowmap indexing changes across frames
|
||||
device->ClearRenderTarget(shadowMapArray_Transparent.get(), transparentShadowClearColor, threadID, light.shadowMap_index);
|
||||
device->ClearRenderTarget(&shadowMapArray_Transparent, transparentShadowClearColor, threadID, light.shadowMap_index);
|
||||
|
||||
// render opaque shadowmap:
|
||||
device->BindRenderTargets(0, nullptr, shadowMapArray_2D.get(), threadID, light.shadowMap_index);
|
||||
device->BindRenderTargets(0, nullptr, &shadowMapArray_2D, threadID, light.shadowMap_index);
|
||||
RenderMeshes(renderQueue, RENDERPASS_SHADOW, RENDERTYPE_OPAQUE, threadID);
|
||||
|
||||
if (GetTransparentShadowsEnabled() && transparentShadowsRequested)
|
||||
{
|
||||
// render transparent shadowmap:
|
||||
Texture2D* rts[] = {
|
||||
shadowMapArray_Transparent.get()
|
||||
const Texture2D* rts[] = {
|
||||
&shadowMapArray_Transparent
|
||||
};
|
||||
device->BindRenderTargets(ARRAYSIZE(rts), rts, shadowMapArray_2D.get(), threadID, light.shadowMap_index);
|
||||
device->BindRenderTargets(ARRAYSIZE(rts), rts, &shadowMapArray_2D, threadID, light.shadowMap_index);
|
||||
RenderMeshes(renderQueue, RENDERPASS_SHADOW, RENDERTYPE_TRANSPARENT | RENDERTYPE_WATER, threadID);
|
||||
}
|
||||
frameAllocators[threadID].free(sizeof(RenderBatch) * renderQueue.batchCount);
|
||||
@@ -5074,8 +5071,8 @@ void DrawForShadowMap(const CameraComponent& camera, GRAPHICSTHREAD threadID, ui
|
||||
}
|
||||
if (!renderQueue.empty())
|
||||
{
|
||||
device->BindRenderTargets(0, nullptr, shadowMapArray_Cube.get(), threadID, light.shadowMap_index);
|
||||
device->ClearDepthStencil(shadowMapArray_Cube.get(), CLEAR_DEPTH, 0.0f, 0, threadID, light.shadowMap_index);
|
||||
device->BindRenderTargets(0, nullptr, &shadowMapArray_Cube, threadID, light.shadowMap_index);
|
||||
device->ClearDepthStencil(&shadowMapArray_Cube, CLEAR_DEPTH, 0.0f, 0, threadID, light.shadowMap_index);
|
||||
|
||||
MiscCB miscCb;
|
||||
miscCb.g_xColor = float4(light.position.x, light.position.y, light.position.z, 1.0f / light.GetRange()); // reciprocal range, to avoid division in shader
|
||||
@@ -5123,11 +5120,11 @@ void BindShadowmaps(SHADERSTAGE stage, GRAPHICSTHREAD threadID)
|
||||
{
|
||||
GraphicsDevice* device = GetDevice();
|
||||
|
||||
device->BindResource(stage, shadowMapArray_2D.get(), TEXSLOT_SHADOWARRAY_2D, threadID);
|
||||
device->BindResource(stage, shadowMapArray_Cube.get(), TEXSLOT_SHADOWARRAY_CUBE, threadID);
|
||||
device->BindResource(stage, &shadowMapArray_2D, TEXSLOT_SHADOWARRAY_2D, threadID);
|
||||
device->BindResource(stage, &shadowMapArray_Cube, TEXSLOT_SHADOWARRAY_CUBE, threadID);
|
||||
if (GetTransparentShadowsEnabled())
|
||||
{
|
||||
device->BindResource(stage, shadowMapArray_Transparent.get(), TEXSLOT_SHADOWARRAY_TRANSPARENT, threadID);
|
||||
device->BindResource(stage, &shadowMapArray_Transparent, TEXSLOT_SHADOWARRAY_TRANSPARENT, threadID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8643,12 +8640,12 @@ void SetGameSpeed(float value) { GameSpeed = max(0, value); }
|
||||
float GetGameSpeed() { return GameSpeed; }
|
||||
void SetOceanEnabled(bool enabled)
|
||||
{
|
||||
SAFE_DELETE(ocean);
|
||||
ocean.reset(nullptr);
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
const Scene& scene = GetScene();
|
||||
ocean = new wiOcean(scene.weather);
|
||||
ocean.reset(new wiOcean(scene.weather));
|
||||
}
|
||||
}
|
||||
bool GetOceanEnabled() { return ocean != nullptr; }
|
||||
|
||||
Reference in New Issue
Block a user