Implemented custom filtered mipchain generator, extended graphicsdevice, updated voxel radiance

This commit is contained in:
turanszkij
2017-03-17 01:13:13 +01:00
parent 18c5ed06be
commit 4653835914
16 changed files with 493 additions and 171 deletions
+2 -4
View File
@@ -39,9 +39,7 @@
// Automatically binds samplers on the shader side:
// Needs macro expansion
#define SAMPLERSTATE_X(name, slot) SamplerState name : register(s ## slot);
#define SAMPLERSTATE(name, slot) SAMPLERSTATE_X(name, slot)
#define SAMPLERCOMPARISONSTATE_X(name, slot) SamplerComparisonState name : register(s ## slot);
#define SAMPLERCOMPARISONSTATE(name, slot) SAMPLERCOMPARISONSTATE_X(name, slot)
#define SAMPLERSTATE(name, slot) SamplerState name : register(s ## slot);
#define SAMPLERCOMPARISONSTATE(name, slot) SamplerComparisonState name : register(s ## slot);
#endif // _SAMPLER_MAPPING_H_
+20
View File
@@ -237,6 +237,16 @@
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Pixel</ShaderType>
</FxCompile>
<FxCompile Include="generateMIPChain3D_SimpleFilterCS.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">4.0</ShaderModel>
</FxCompile>
<FxCompile Include="grassGS.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Geometry</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4.0</ShaderModel>
@@ -909,6 +919,16 @@
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">4.0</ShaderModel>
</FxCompile>
<FxCompile Include="voxelSceneCopyClear_TemporalSmoothing.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">4.0</ShaderModel>
</FxCompile>
<FxCompile Include="voxelVS.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Vertex</ShaderType>
@@ -543,6 +543,12 @@
<FxCompile Include="voxelClearOnlyNormalCS.hlsl">
<Filter>CS</Filter>
</FxCompile>
<FxCompile Include="generateMIPChain3D_SimpleFilterCS.hlsl">
<Filter>CS</Filter>
</FxCompile>
<FxCompile Include="voxelSceneCopyClear_TemporalSmoothing.hlsl">
<Filter>CS</Filter>
</FxCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="PS">
@@ -0,0 +1,18 @@
#include "globals.hlsli"
TEXTURE3D(input, float4, 0);
RWTEXTURE3D(output, float4, 0);
SAMPLERSTATE(samplerstate, SSLOT_ONDEMAND0);
[numthreads(8, 8, 8)]
void main( uint3 DTid : SV_DispatchThreadID )
{
uint3 dim;
output.GetDimensions(dim.x, dim.y, dim.z);
if (DTid.x < dim.x && DTid.y < dim.y && DTid.z < dim.z)
{
output[DTid] = input.SampleLevel(samplerstate, ((float3)DTid + 0.5f) / (float3)dim, 0);
}
}
+1 -1
View File
@@ -85,7 +85,7 @@ inline float4 ConeTraceReflection(in Texture3D<float4> voxels, in float3 uvw, in
tc += coneVec * (1 + mip);
float4 sam = voxels.SampleLevel(sampler_point_clamp, tc, mip);
float4 sam = voxels.SampleLevel(sampler_linear_clamp, tc, mip);
accumulation.a += sam.a;
accumulation.rgb += sam.rgb * sam.a;
+1 -2
View File
@@ -1,8 +1,6 @@
#include "globals.hlsli"
#include "voxelHF.hlsli"
#define TEMPORAL_SMOOTHING
RWSTRUCTUREDBUFFER(input_output, VoxelType, 0);
RWTEXTURE3D(output_emission, float4, 1);
@@ -29,6 +27,7 @@ void main( uint3 DTid : SV_DispatchThreadID )
}
else
{
// This operation requires Feature: Typed UAV additional format loads!
output_emission[writecoord] = lerp(output_emission[writecoord], float4(color.rgb, 1), 0.2f);
}
#else
@@ -0,0 +1,3 @@
#define TEMPORAL_SMOOTHING
#include "voxelSceneCopyClearCS.hlsl"
+2
View File
@@ -227,8 +227,10 @@ enum CSTYPES
CSTYPE_TILEDLIGHTCULLING_DEBUG,
CSTYPE_RESOLVEMSAADEPTHSTENCIL,
CSTYPE_VOXELSCENECOPYCLEAR,
CSTYPE_VOXELSCENECOPYCLEAR_TEMPORALSMOOTHING,
CSTYPE_VOXELRADIANCESECONDARYBOUNCE,
CSTYPE_VOXELCLEARONLYNORMAL,
CSTYPE_GENERATEMIPCHAIN3D_SIMPLEFILTER,
CSTYPE_LAST
};
+11 -11
View File
@@ -87,17 +87,17 @@ namespace wiGraphicsTypes
virtual void BindViewports(UINT NumViewports, const ViewPort *pViewports, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
virtual void BindRenderTargetsUAVs(UINT NumViews, Texture* const *ppRenderTargets, Texture2D* depthStencilTexture, GPUUnorderedResource* const *ppUAVs, int slotUAV, int countUAV,
GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, UINT arrayIndex = 0) = 0;
virtual void BindRenderTargets(UINT NumViews, Texture* const *ppRenderTargets, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, UINT arrayIndex = 0) = 0;
virtual void ClearRenderTarget(Texture* pTexture, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, UINT arrayIndex = 0) = 0;
virtual void ClearDepthStencil(Texture2D* pTexture, UINT ClearFlags, FLOAT Depth, UINT8 Stencil, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, UINT arrayIndex = 0) = 0;
virtual void BindResourcePS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
virtual void BindResourceVS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
virtual void BindResourceGS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
virtual void BindResourceDS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
virtual void BindResourceHS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
virtual void BindResourceCS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
virtual void BindUnorderedAccessResourceCS(const GPUUnorderedResource* buffer, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int arrayIndex = -1) = 0;
virtual void BindRenderTargets(UINT NumViews, Texture* const *ppRenderTargets, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int arrayIndex = -1) = 0;
virtual void ClearRenderTarget(Texture* pTexture, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int arrayIndex = -1) = 0;
virtual void ClearDepthStencil(Texture2D* pTexture, UINT ClearFlags, FLOAT Depth, UINT8 Stencil, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int arrayIndex = -1) = 0;
virtual void BindResourcePS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int arrayIndex = -1) = 0;
virtual void BindResourceVS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int arrayIndex = -1) = 0;
virtual void BindResourceGS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int arrayIndex = -1) = 0;
virtual void BindResourceDS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int arrayIndex = -1) = 0;
virtual void BindResourceHS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int arrayIndex = -1) = 0;
virtual void BindResourceCS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int arrayIndex = -1) = 0;
virtual void BindUnorderedAccessResourceCS(const GPUUnorderedResource* buffer, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int arrayIndex = -1) = 0;
virtual void UnBindResources(int slot, int num, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
virtual void UnBindUnorderedAccessResources(int slot, int num, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
virtual void BindSamplerPS(const Sampler* sampler, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
File diff suppressed because it is too large Load Diff
+11 -11
View File
@@ -69,17 +69,17 @@ namespace wiGraphicsTypes
virtual void BindViewports(UINT NumViewports, const ViewPort *pViewports, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindRenderTargetsUAVs(UINT NumViews, Texture* const *ppRenderTargets, Texture2D* depthStencilTexture, GPUUnorderedResource* const *ppUAVs, int slotUAV, int countUAV,
GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, UINT arrayIndex = 0) override;
virtual void BindRenderTargets(UINT NumViews, Texture* const *ppRenderTargets, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, UINT arrayIndex = 0) override;
virtual void ClearRenderTarget(Texture* pTexture, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, UINT arrayIndex = 0) override;
virtual void ClearDepthStencil(Texture2D* pTexture, UINT ClearFlags, FLOAT Depth, UINT8 Stencil, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, UINT arrayIndex = 0) override;
virtual void BindResourcePS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindResourceVS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindResourceGS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindResourceDS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindResourceHS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindResourceCS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindUnorderedAccessResourceCS(const GPUUnorderedResource* buffer, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int arrayIndex = -1) override;
virtual void BindRenderTargets(UINT NumViews, Texture* const *ppRenderTargets, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int arrayIndex = -1) override;
virtual void ClearRenderTarget(Texture* pTexture, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int arrayIndex = -1) override;
virtual void ClearDepthStencil(Texture2D* pTexture, UINT ClearFlags, FLOAT Depth, UINT8 Stencil, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int arrayIndex = -1) override;
virtual void BindResourcePS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int arrayIndex = -1) override;
virtual void BindResourceVS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int arrayIndex = -1) override;
virtual void BindResourceGS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int arrayIndex = -1) override;
virtual void BindResourceDS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int arrayIndex = -1) override;
virtual void BindResourceHS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int arrayIndex = -1) override;
virtual void BindResourceCS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int arrayIndex = -1) override;
virtual void BindUnorderedAccessResourceCS(const GPUUnorderedResource* buffer, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int arrayIndex = -1) override;
virtual void UnBindResources(int slot, int num, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void UnBindUnorderedAccessResources(int slot, int num, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindSamplerPS(const Sampler* sampler, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
+27 -13
View File
@@ -68,20 +68,28 @@ namespace wiGraphicsTypes
GPUResource::GPUResource()
{
SAFE_INIT(shaderResourceView_DX11);
SAFE_INIT(SRV_DX11);
}
GPUResource::~GPUResource()
{
SAFE_RELEASE(shaderResourceView_DX11);
SAFE_RELEASE(SRV_DX11);
for (auto& x : additionalSRVs_DX11)
{
SAFE_RELEASE(x);
}
}
GPUUnorderedResource::GPUUnorderedResource()
{
SAFE_INIT(unorderedAccessView_DX11);
SAFE_INIT(UAV_DX11);
}
GPUUnorderedResource::~GPUUnorderedResource()
{
SAFE_RELEASE(unorderedAccessView_DX11);
SAFE_RELEASE(UAV_DX11);
for (auto& x : additionalUAVs_DX11)
{
SAFE_RELEASE(x);
}
}
GPUBuffer::GPUBuffer() : GPUResource(), GPUUnorderedResource()
@@ -149,12 +157,16 @@ namespace wiGraphicsTypes
SAFE_DELETE(vertexLayout);
}
Texture::Texture() : GPUResource(), GPUUnorderedResource(), independentRTVArraySlices(false), independentRTVCubemapFaces(false)
Texture::Texture() : GPUResource(), GPUUnorderedResource()
, independentRTVArraySlices(false), independentRTVCubemapFaces(false)
, independentSRVMIPs(false), independentUAVMIPs(false)
{
SAFE_INIT(RTV_DX11);
}
Texture::~Texture()
{
for (auto& x : renderTargetViews_DX11)
SAFE_RELEASE(RTV_DX11);
for (auto& x : additionalRTVs_DX11)
{
SAFE_RELEASE(x);
}
@@ -163,17 +175,17 @@ namespace wiGraphicsTypes
{
independentRTVArraySlices = value;
}
bool Texture::IsIndepententRenderTargetArraySlices()
{
return independentRTVArraySlices;
}
void Texture::RequestIndepententRenderTargetCubemapFaces(bool value)
{
independentRTVCubemapFaces = value;
}
bool Texture::IsIndepententRenderTargetCubemapFaces()
void Texture::RequestIndepententShaderResourcesForMIPs(bool value)
{
return independentRTVCubemapFaces;
independentSRVMIPs = value;
}
void Texture::RequestIndepententUnorderedAccessResourcesForMIPs(bool value)
{
independentUAVMIPs = value;
}
Texture1D::Texture1D() :Texture()
@@ -188,11 +200,13 @@ namespace wiGraphicsTypes
Texture2D::Texture2D() :Texture()
{
SAFE_INIT(texture2D_DX11);
SAFE_INIT(DSV_DX11);
}
Texture2D::~Texture2D()
{
SAFE_RELEASE(texture2D_DX11);
for (auto& x : depthStencilViews_DX11)
SAFE_RELEASE(DSV_DX11);
for (auto& x : additionalDSVs_DX11)
{
SAFE_RELEASE(x);
}
+17 -8
View File
@@ -122,7 +122,8 @@ namespace wiGraphicsTypes
{
friend class GraphicsDevice_DX11;
private:
ID3D11ShaderResourceView* shaderResourceView_DX11;
ID3D11ShaderResourceView* SRV_DX11; // main resource SRV
vector<ID3D11ShaderResourceView*> additionalSRVs_DX11; // can be used for sub-resources if requested
protected:
GPUResource();
@@ -133,7 +134,8 @@ namespace wiGraphicsTypes
{
friend class GraphicsDevice_DX11;
private:
ID3D11UnorderedAccessView* unorderedAccessView_DX11;
ID3D11UnorderedAccessView* UAV_DX11; // main resource UAV
vector<ID3D11UnorderedAccessView*> additionalUAVs_DX11; // can be used for sub-resources if requested
protected:
GPUUnorderedResource();
@@ -232,19 +234,25 @@ namespace wiGraphicsTypes
{
friend class GraphicsDevice_DX11;
private:
vector<ID3D11RenderTargetView*> renderTargetViews_DX11;
ID3D11RenderTargetView* RTV_DX11;
vector<ID3D11RenderTargetView*> additionalRTVs_DX11;
bool independentRTVArraySlices;
bool independentRTVCubemapFaces;
bool independentSRVMIPs;
bool independentUAVMIPs;
public:
Texture();
virtual ~Texture();
// if true, then each array slice will get a unique rendertarget
void RequestIndepententRenderTargetArraySlices(bool value);
bool IsIndepententRenderTargetArraySlices();
// if true, then each face of the cubemap will get a unique rendertarget
void RequestIndepententRenderTargetCubemapFaces(bool value);
bool IsIndepententRenderTargetCubemapFaces();
// if true, then each miplevel will get unique shader resource
void RequestIndepententShaderResourcesForMIPs(bool value);
// if true, then each miplevel will get unique unordered access resource
void RequestIndepententUnorderedAccessResourcesForMIPs(bool value);
};
class Texture1D : public Texture
@@ -264,9 +272,10 @@ namespace wiGraphicsTypes
{
friend class GraphicsDevice_DX11;
private:
vector<ID3D11DepthStencilView*> depthStencilViews_DX11;
ID3D11Texture2D* texture2D_DX11;
Texture2DDesc desc;
ID3D11DepthStencilView* DSV_DX11;
vector<ID3D11DepthStencilView*> additionalDSVs_DX11;
ID3D11Texture2D* texture2D_DX11;
Texture2DDesc desc;
public:
Texture2D();
virtual ~Texture2D();
+69 -8
View File
@@ -782,8 +782,10 @@ void wiRenderer::LoadShaders()
computeShaders[CSTYPE_TILEDLIGHTCULLING_DEBUG] = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "lightCullingCS_DEBUG.cso", wiResourceManager::COMPUTESHADER));
computeShaders[CSTYPE_RESOLVEMSAADEPTHSTENCIL] = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "resolveMSAADepthStencilCS.cso", wiResourceManager::COMPUTESHADER));
computeShaders[CSTYPE_VOXELSCENECOPYCLEAR] = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "voxelSceneCopyClearCS.cso", wiResourceManager::COMPUTESHADER));
computeShaders[CSTYPE_VOXELSCENECOPYCLEAR_TEMPORALSMOOTHING] = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "voxelSceneCopyClear_TemporalSmoothing.cso", wiResourceManager::COMPUTESHADER));
computeShaders[CSTYPE_VOXELRADIANCESECONDARYBOUNCE] = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "voxelRadianceSecondaryBounceCS.cso", wiResourceManager::COMPUTESHADER));
computeShaders[CSTYPE_VOXELCLEARONLYNORMAL] = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "voxelClearOnlyNormalCS.cso", wiResourceManager::COMPUTESHADER));
computeShaders[CSTYPE_GENERATEMIPCHAIN3D_SIMPLEFILTER] = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "generateMIPChain3D_SimpleFilterCS.cso", wiResourceManager::COMPUTESHADER));
hullShaders[HSTYPE_OBJECT] = static_cast<HullShader*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "objectHS.cso", wiResourceManager::HULLSHADER));
@@ -3999,22 +4001,23 @@ void wiRenderer::VoxelRadiance(GRAPHICSTHREAD threadID)
desc.Depth = voxelSceneData.res;
desc.MipLevels = 0;
desc.Format = FORMAT_R16G16B16A16_FLOAT;
desc.BindFlags = BIND_RENDER_TARGET | BIND_UNORDERED_ACCESS | BIND_SHADER_RESOURCE;
desc.BindFlags = BIND_UNORDERED_ACCESS | BIND_SHADER_RESOURCE;
desc.Usage = USAGE_DEFAULT;
desc.CPUAccessFlags = 0;
desc.MiscFlags = RESOURCE_MISC_GENERATE_MIPS;
desc.MiscFlags = 0;
textures[TEXTYPE_3D_VOXELRADIANCE] = new Texture3D;
textures[TEXTYPE_3D_VOXELRADIANCE]->RequestIndepententShaderResourcesForMIPs(true);
textures[TEXTYPE_3D_VOXELRADIANCE]->RequestIndepententUnorderedAccessResourcesForMIPs(true);
HRESULT hr = GetDevice()->CreateTexture3D(&desc, nullptr, (Texture3D**)&textures[TEXTYPE_3D_VOXELRADIANCE]);
assert(SUCCEEDED(hr));
textures[TEXTYPE_3D_VOXELRADIANCE_HELPER] = new Texture3D;
hr = GetDevice()->CreateTexture3D(&desc, nullptr, (Texture3D**)&textures[TEXTYPE_3D_VOXELRADIANCE_HELPER]);
assert(SUCCEEDED(hr));
}
if (voxelSceneData.secondaryBounceEnabled && textures[TEXTYPE_3D_VOXELRADIANCE_HELPER] == nullptr)
{
Texture3DDesc desc = ((Texture3D*)textures[TEXTYPE_3D_VOXELRADIANCE])->GetDesc();
textures[TEXTYPE_3D_VOXELRADIANCE_HELPER] = new Texture3D;
textures[TEXTYPE_3D_VOXELRADIANCE_HELPER]->RequestIndepententShaderResourcesForMIPs(true);
textures[TEXTYPE_3D_VOXELRADIANCE_HELPER]->RequestIndepententUnorderedAccessResourcesForMIPs(true);
HRESULT hr = GetDevice()->CreateTexture3D(&desc, nullptr, (Texture3D**)&textures[TEXTYPE_3D_VOXELRADIANCE_HELPER]);
assert(SUCCEEDED(hr));
}
@@ -4085,7 +4088,14 @@ void wiRenderer::VoxelRadiance(GRAPHICSTHREAD threadID)
GetDevice()->BindUnorderedAccessResourceCS(resourceBuffers[RBTYPE_VOXELSCENE], 0, threadID);
GetDevice()->BindUnorderedAccessResourceCS(textures[TEXTYPE_3D_VOXELRADIANCE], 1, threadID);
GetDevice()->BindCS(computeShaders[CSTYPE_VOXELSCENECOPYCLEAR], threadID);
if (GetDevice()->CheckCapability(GraphicsDevice::GRAPHICSDEVICE_CAPABILITY_UNORDEREDACCESSTEXTURE_LOAD_FORMAT_EXT))
{
GetDevice()->BindCS(computeShaders[CSTYPE_VOXELSCENECOPYCLEAR_TEMPORALSMOOTHING], threadID);
}
else
{
GetDevice()->BindCS(computeShaders[CSTYPE_VOXELSCENECOPYCLEAR], threadID);
}
GetDevice()->Dispatch((UINT)(voxelSceneData.res * voxelSceneData.res * voxelSceneData.res / 1024), 1, 1, threadID);
GetDevice()->EventEnd();
@@ -4094,7 +4104,7 @@ void wiRenderer::VoxelRadiance(GRAPHICSTHREAD threadID)
GetDevice()->EventBegin("Voxel Radiance Secondary Bounce", threadID);
GetDevice()->UnBindUnorderedAccessResources(1, 1, threadID);
// Pre-integrate the voxel texture by creating blurred mip levels:
GetDevice()->GenerateMips(textures[TEXTYPE_3D_VOXELRADIANCE], threadID);
GenerateMipChain((Texture3D*)textures[TEXTYPE_3D_VOXELRADIANCE], MIPGENFILTER_LINEAR, threadID);
GetDevice()->BindUnorderedAccessResourceCS(textures[TEXTYPE_3D_VOXELRADIANCE_HELPER], 0, threadID);
GetDevice()->BindResourceCS(textures[TEXTYPE_3D_VOXELRADIANCE], 0, threadID);
GetDevice()->BindResourceCS(resourceBuffers[RBTYPE_VOXELSCENE], 1, threadID);
@@ -4117,7 +4127,7 @@ void wiRenderer::VoxelRadiance(GRAPHICSTHREAD threadID)
// Pre-integrate the voxel texture by creating blurred mip levels:
GetDevice()->GenerateMips(result, threadID);
GenerateMipChain(result, MIPGENFILTER_LINEAR, threadID);
}
if (voxelHelper)
@@ -4324,6 +4334,57 @@ void wiRenderer::ResolveMSAADepthBuffer(Texture2D* dst, Texture2D* src, GRAPHICS
GetDevice()->EventEnd();
}
void wiRenderer::GenerateMipChain(Texture1D* texture, MIPGENFILTER filter, GRAPHICSTHREAD threadID)
{
assert(0 && "Not implemented!");
}
void wiRenderer::GenerateMipChain(Texture2D* texture, MIPGENFILTER filter, GRAPHICSTHREAD threadID)
{
assert(0 && "Not implemented!");
}
void wiRenderer::GenerateMipChain(Texture3D* texture, MIPGENFILTER filter, GRAPHICSTHREAD threadID)
{
Texture3DDesc desc = texture->GetDesc();
if (desc.MipLevels < 2)
{
assert(0);
return;
}
GetDevice()->EventBegin("GenerateMipChain 3D", threadID);
switch (filter)
{
case wiRenderer::MIPGENFILTER_POINT:
GetDevice()->BindCS(computeShaders[CSTYPE_GENERATEMIPCHAIN3D_SIMPLEFILTER], threadID);
GetDevice()->BindSamplerCS(samplers[SSLOT_POINT_CLAMP], SSLOT_ONDEMAND0, threadID);
break;
case wiRenderer::MIPGENFILTER_LINEAR:
GetDevice()->BindCS(computeShaders[CSTYPE_GENERATEMIPCHAIN3D_SIMPLEFILTER], threadID);
GetDevice()->BindSamplerCS(samplers[SSLOT_LINEAR_CLAMP], SSLOT_ONDEMAND0, threadID);
break;
case wiRenderer::MIPGENFILTER_GAUSSIAN:
assert(0 && "Not implemented!");
break;
}
for (UINT i = 0; i < desc.MipLevels - 1; ++i)
{
GetDevice()->BindUnorderedAccessResourceCS(texture, 0, threadID, i + 1);
GetDevice()->BindResourceCS(texture, 0, threadID, i);
desc.Width = max(1, desc.Width / 2);
desc.Height = max(1, desc.Height / 2);
desc.Depth = max(1, desc.Depth / 2);
GetDevice()->Dispatch(max(1, desc.Width / 8), max(1, desc.Height / 8), max(1, desc.Depth / 8), threadID);
}
GetDevice()->UnBindResources(0, 1, threadID);
GetDevice()->UnBindUnorderedAccessResources(0, 1, threadID);
GetDevice()->BindCS(nullptr, threadID);
GetDevice()->EventEnd();
}
void wiRenderer::ManageDecalAtlas(GRAPHICSTHREAD threadID)
{
+10
View File
@@ -454,6 +454,16 @@ public:
static void ComputeTiledLightCulling(GRAPHICSTHREAD threadID);
static void ResolveMSAADepthBuffer(wiGraphicsTypes::Texture2D* dst, wiGraphicsTypes::Texture2D* src, GRAPHICSTHREAD threadID);
enum MIPGENFILTER
{
MIPGENFILTER_POINT,
MIPGENFILTER_LINEAR,
MIPGENFILTER_GAUSSIAN,
};
static void GenerateMipChain(wiGraphicsTypes::Texture1D* texture, MIPGENFILTER filter, GRAPHICSTHREAD threadID);
static void GenerateMipChain(wiGraphicsTypes::Texture2D* texture, MIPGENFILTER filter, GRAPHICSTHREAD threadID);
static void GenerateMipChain(wiGraphicsTypes::Texture3D* texture, MIPGENFILTER filter, GRAPHICSTHREAD threadID);
static void ManageDecalAtlas(GRAPHICSTHREAD threadID);
static XMVECTOR GetSunPosition();
+1 -1
View File
@@ -7,7 +7,7 @@ namespace wiVersion
// minor features, major updates
const int minor = 11;
// minor bug fixes, alterations, refactors, updates
const int revision = 9;
const int revision = 10;
long GetVersion()