Danbias/Code/OysterGraphics/Render/Resources.cpp

495 lines
18 KiB
C++
Raw Normal View History

#pragma once
2014-02-07 15:52:07 +01:00
#include "Resources.h"
#include "..\Definitions\GraphicalDefinition.h"
typedef Oyster::Graphics::Core::PipelineManager::ShaderType ShaderType;
typedef Oyster::Graphics::Core::PipelineManager::Get GetShader;
typedef Oyster::Graphics::Core::PipelineManager Shader;
typedef Oyster::Graphics::Core::Buffer Buffer;
2014-02-07 11:09:59 +01:00
const std::wstring PathToHLSL = L"..\\..\\Code\\OysterGraphics\\Shader\\Passes\\";
const std::wstring PathToCSO = L"..\\Content\\Shaders\\";
2014-01-08 07:01:59 +01:00
const int KernelSize = 10;
2014-01-22 16:31:33 +01:00
const int SampleSpread = 16;
2014-01-08 07:01:59 +01:00
2014-02-11 13:29:19 +01:00
const int MAX_LETTER_COUNT=60;
namespace Oyster
{
namespace Graphics
{
namespace Render
{
2014-02-07 15:52:07 +01:00
ID3D11RenderTargetView* Resources::GBufferRTV[Resources::GBufferSize] = {0};
ID3D11ShaderResourceView* Resources::GBufferSRV[Resources::GBufferSize] = {0};
2014-02-07 15:52:07 +01:00
ID3D11UnorderedAccessView* Resources::LBufferUAV[Resources::LBufferSize] = {0};
ID3D11ShaderResourceView* Resources::LBufferSRV[Resources::LBufferSize] = {0};
2014-02-07 13:46:55 +01:00
2014-02-07 15:52:07 +01:00
ID3D11UnorderedAccessView* Resources::Blur::BufferUAV = {0};
ID3D11ShaderResourceView* Resources::Blur::BufferSRV = {0};
2014-02-07 15:52:07 +01:00
Shader::RenderPass Resources::Gather::Pass;
Shader::RenderPass Resources::Light::Pass;
2014-02-07 16:51:35 +01:00
Shader::RenderPass Resources::Post::Pass;
2014-02-07 15:52:07 +01:00
Shader::RenderPass Resources::Gui::Pass;
2014-02-11 13:29:19 +01:00
Shader::RenderPass Resources::Gui::Text::Pass;
2014-02-07 15:52:07 +01:00
Shader::RenderPass Resources::Blur::VertPass; //Set this pass second when doing a "fullscreen" blur
Shader::RenderPass Resources::Blur::HorPass; //Set this pass first when doing a "fullscreen" blur
2014-02-07 15:52:07 +01:00
Buffer Resources::Gather::ModelData = Buffer();
Buffer Resources::Gather::AnimationData = Buffer();
Buffer Resources::Light::LightConstantsData = Buffer();
Buffer Resources::Gui::Data = Buffer();
2014-02-11 13:29:19 +01:00
Buffer Resources::Gui::Text::Vertex = Buffer();
2014-02-10 01:03:10 +01:00
Buffer Resources::Post::Data = Buffer();
2014-02-07 15:52:07 +01:00
Buffer Resources::Light::PointLightsData = Buffer();
ID3D11ShaderResourceView* Resources::Light::PointLightView = NULL;
2014-02-07 15:52:07 +01:00
ID3D11ShaderResourceView* Resources::Light::SSAOKernel = NULL;
ID3D11ShaderResourceView* Resources::Light::SSAORandom = NULL;
2014-01-08 07:01:59 +01:00
2014-02-07 15:52:07 +01:00
ID3D11RasterizerState* Resources::RenderStates::rs = NULL;
ID3D11SamplerState** Resources::RenderStates::ss = new ID3D11SamplerState*[1];
ID3D11DepthStencilState* Resources::RenderStates::dsState = NULL;
2014-02-11 13:29:19 +01:00
ID3D11BlendState* Resources::RenderStates::bs = NULL;
ID3D11ShaderResourceView* Resources::Gui::Text::Font = NULL;
2014-02-05 16:54:57 +01:00
2014-02-07 15:52:07 +01:00
Core::Init::State Resources::InitShaders()
{
2014-02-07 11:09:59 +01:00
#ifdef _DEBUG
std::wstring path = PathToHLSL+L"Gather\\";
std::wstring end = L".hlsl";
#else
std::wstring path = PathToCSO;
std::wstring end = L".cso";
#endif
//Load Shaders
2014-02-07 11:09:59 +01:00
Core::PipelineManager::Init(path + L"GatherPixel" + end, ShaderType::Pixel, L"Gather");
Core::PipelineManager::Init(path + L"GatherVertex" + end, ShaderType::Vertex, L"Gather");
#ifdef _DEBUG
path = PathToHLSL+L"Light\\";
#endif
Core::PipelineManager::Init(path + L"LightPass" + end, ShaderType::Compute, L"LightPass");
2014-02-07 11:09:59 +01:00
#ifdef _DEBUG
path = PathToHLSL+L"Post\\";
#endif
Core::PipelineManager::Init(path + L"PostPass" + end, ShaderType::Compute, L"PostPass");
2014-02-07 15:52:07 +01:00
#ifdef _DEBUG
path = PathToHLSL+L"Blur\\";
#endif
2014-02-07 13:46:55 +01:00
Core::PipelineManager::Init(path + L"BlurHor" + end, ShaderType::Compute, L"BlurHor");
Core::PipelineManager::Init(path + L"BlurVert" + end, ShaderType::Compute, L"BlurVert");
2014-02-07 11:09:59 +01:00
#ifdef _DEBUG
path = PathToHLSL+L"2D\\";
#endif
Core::PipelineManager::Init(path + L"2DVertex" + end,ShaderType::Vertex, L"2D");
Core::PipelineManager::Init(path + L"2DGeometry" + end,ShaderType::Geometry, L"2D");
Core::PipelineManager::Init(path + L"2DPixel" + end,ShaderType::Pixel, L"2D");
2014-02-11 13:29:19 +01:00
#ifdef _DEBUG
path = PathToHLSL+L"2D\\Text\\";
#endif
Core::PipelineManager::Init(path + L"2DTextVertex" + end,ShaderType::Vertex, L"2DText");
Core::PipelineManager::Init(path + L"2DTextGeometry" + end,ShaderType::Geometry, L"2DText");
2014-02-07 11:09:59 +01:00
2014-01-08 07:01:59 +01:00
return Core::Init::State::Success;
}
2014-02-07 15:52:07 +01:00
Core::Init::State Resources::InitBuffers()
2014-01-08 07:01:59 +01:00
{
//Create Buffers
Buffer::BUFFER_INIT_DESC desc;
2014-01-08 07:01:59 +01:00
desc.ElementSize = sizeof(Definitions::PerModel);
desc.NumElements = 1;
desc.InitData = NULL;
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_VS;
desc.Usage = Buffer::BUFFER_USAGE::BUFFER_CPU_WRITE_DISCARD;
2014-02-07 15:52:07 +01:00
Gather::ModelData.Init(desc);
2014-01-27 14:24:13 +01:00
desc.NumElements = 1;
desc.ElementSize = sizeof(Definitions::AnimationData);
2014-02-07 15:52:07 +01:00
Gather::AnimationData.Init(desc);
2014-02-07 11:09:59 +01:00
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_GS;
desc.NumElements = 1;
desc.ElementSize = sizeof(Definitions::GuiData);
2014-02-07 16:51:35 +01:00
Gui::Data.Init(desc);
2014-02-07 11:09:59 +01:00
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_CS;
2014-02-10 01:03:10 +01:00
desc.ElementSize = sizeof(Definitions::PostData);
Post::Data.Init(desc);
desc.ElementSize = sizeof(Definitions::LightConstants);
2014-02-07 15:52:07 +01:00
Light::LightConstantsData.Init(desc);
desc.ElementSize = sizeof(Definitions::Pointlight);
desc.NumElements = MaxLightSize;
desc.Type = Buffer::STRUCTURED_BUFFER;
2014-02-07 15:52:07 +01:00
Light::PointLightsData.Init(desc);
2014-02-11 13:29:19 +01:00
desc.Type = Buffer::BUFFER_TYPE::VERTEX_BUFFER;
desc.ElementSize = sizeof(Definitions::Text2D);
desc.NumElements = MAX_LETTER_COUNT;
Gui::Text::Vertex.Init(desc);
2014-02-07 15:52:07 +01:00
return Core::Init::Success;
}
2014-02-07 15:52:07 +01:00
Core::Init::State Resources::InitRenderStates()
{
2014-01-08 07:01:59 +01:00
////Create States
D3D11_RASTERIZER_DESC rdesc;
rdesc.CullMode = D3D11_CULL_BACK;
rdesc.FillMode = D3D11_FILL_SOLID;
2014-01-17 08:51:12 +01:00
rdesc.FrontCounterClockwise = false;
rdesc.DepthBias = 0;
rdesc.DepthBiasClamp = 0;
rdesc.DepthClipEnable = true;
rdesc.SlopeScaledDepthBias = 0;
rdesc.ScissorEnable = false;
rdesc.MultisampleEnable = false;
rdesc.AntialiasedLineEnable = false;
2014-02-07 15:52:07 +01:00
Oyster::Graphics::Core::device->CreateRasterizerState(&rdesc,&RenderStates::rs);
D3D11_SAMPLER_DESC sdesc;
sdesc.Filter = D3D11_FILTER_ANISOTROPIC;
sdesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
sdesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
sdesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
sdesc.MipLODBias = 0;
sdesc.MaxAnisotropy =4;
sdesc.ComparisonFunc = D3D11_COMPARISON_LESS_EQUAL;
*sdesc.BorderColor = *Oyster::Math::Float4(1,1,1,1).element;
sdesc.MinLOD = 0;
sdesc.MaxLOD = D3D11_FLOAT32_MAX;
2014-02-07 15:52:07 +01:00
Oyster::Graphics::Core::device->CreateSamplerState(&sdesc,RenderStates::ss);
D3D11_DEPTH_STENCIL_DESC ddesc;
ddesc.DepthEnable = true;
ddesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
ddesc.DepthFunc = D3D11_COMPARISON_LESS;
ddesc.StencilEnable = true;
ddesc.StencilReadMask = 0xFF;
ddesc.StencilWriteMask = 0xFF;
ddesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
ddesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR;
ddesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
ddesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
ddesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
ddesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR;
ddesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
ddesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
2014-02-07 15:52:07 +01:00
Core::device->CreateDepthStencilState(&ddesc,&RenderStates::dsState);
2014-02-11 13:29:19 +01:00
D3D11_BLEND_DESC bdesc;
bdesc.AlphaToCoverageEnable = true;
bdesc.IndependentBlendEnable = false;
bdesc.RenderTarget[0].BlendEnable = true;
bdesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
bdesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
bdesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
bdesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
bdesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE;
bdesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_MAX;
bdesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
Core::device->CreateBlendState(&bdesc,&RenderStates::bs);
2014-02-07 15:52:07 +01:00
return Core::Init::Success;
}
2014-02-07 15:52:07 +01:00
Core::Init::State Resources::InitViews()
{
//Create Views
2014-02-07 15:52:07 +01:00
for(int i = 0; i< GBufferSize; ++i)
{
Core::Init::CreateLinkedShaderResourceFromTexture(&GBufferRTV[i],&GBufferSRV[i],NULL);
}
2014-02-07 15:52:07 +01:00
for(int i = 0; i < LBufferSize; ++i)
2014-01-08 07:01:59 +01:00
{
Core::Init::CreateLinkedShaderResourceFromTexture(NULL,&LBufferSRV[i],&LBufferUAV[i]);
}
2014-02-07 15:52:07 +01:00
Buffer* b = &Light::PointLightsData;
2014-02-07 15:52:07 +01:00
Core::Init::CreateLinkedShaderResourceFromStructuredBuffer(&b,&Light::PointLightView,NULL);
srand((unsigned int)time(0));
2014-01-22 16:31:33 +01:00
2014-01-08 07:01:59 +01:00
//SSAO
Math::Vector3 kernel[KernelSize];
Math::Vector3 random[SampleSpread];
for(int i = 0;i < KernelSize; ++i)
{
kernel[i] = Oyster::Math::Vector3::null;
while( kernel[i] == Oyster::Math::Vector3::null )
{
kernel[i] = Oyster::Math::Vector3(
(float)rand() / (RAND_MAX + 1) * (1 - -1) + -1,
(float)rand() / (RAND_MAX + 1) * (1 - -1) + -1,
(float)rand() / (RAND_MAX + 1) * (1 - 0) + 0);
}
kernel[i].Normalize();
float scale = float(i) / float(KernelSize);
scale = (0.1f*(1 - scale * scale) + 1.0f *( scale * scale));
kernel[i] *= scale;
}
for( int i = 0; i < SampleSpread; ++i)
{
random[i] = Oyster::Math::Vector3::null;
while( random[i] == Oyster::Math::Vector3::null )
{
random[i] = Oyster::Math::Vector3(
(float)rand() / (RAND_MAX + 1) * (1 - -1)+ -1,
2014-01-22 16:31:33 +01:00
/*(float)rand() / (RAND_MAX + 1) * (1 - -1)+ -1,*/
1.0f,
2014-01-08 07:01:59 +01:00
0.0f);
}
random[i].Normalize();
}
D3D11_TEXTURE1D_DESC T1desc;
T1desc.Width = KernelSize;
T1desc.MipLevels = T1desc.ArraySize = 1;
T1desc.Format = DXGI_FORMAT_R32G32B32_FLOAT;
T1desc.Usage = D3D11_USAGE_DEFAULT;
T1desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
T1desc.CPUAccessFlags = 0;
T1desc.MiscFlags = 0;
2014-01-08 07:01:59 +01:00
D3D11_SUBRESOURCE_DATA sphere;
sphere.pSysMem = kernel;
D3D11_SUBRESOURCE_DATA rnd;
rnd.pSysMem = random;
2014-02-07 08:34:01 +01:00
rnd.SysMemPitch = (UINT)(sqrt(SampleSpread) * sizeof(Oyster::Math::Vector3));
2014-01-22 16:31:33 +01:00
ID3D11Texture1D *pTexture1;
Core::device->CreateTexture1D( &T1desc, &sphere, &pTexture1 );
2014-02-07 15:52:07 +01:00
Core::device->CreateShaderResourceView( pTexture1, 0, &Light::SSAOKernel );
2014-01-22 16:31:33 +01:00
pTexture1->Release();
D3D11_TEXTURE2D_DESC T2desc;
T2desc.Width = KernelSize;
T2desc.MipLevels = T2desc.ArraySize = 1;
T2desc.Format = DXGI_FORMAT_R32G32B32_FLOAT;
T2desc.Usage = D3D11_USAGE_DEFAULT;
T2desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
T2desc.CPUAccessFlags = 0;
T2desc.MiscFlags = 0;
2014-02-07 08:34:01 +01:00
T2desc.Height = (UINT)sqrt(SampleSpread);
T2desc.Width = (UINT)(SampleSpread/sqrt(SampleSpread));
2014-01-22 16:31:33 +01:00
T2desc.SampleDesc.Quality = 0;
T2desc.SampleDesc.Count = 1;
ID3D11Texture2D *pTexture2;
Core::device->CreateTexture2D( &T2desc, &rnd, &pTexture2 );
2014-02-07 15:52:07 +01:00
Core::device->CreateShaderResourceView( (pTexture2), 0, &Light::SSAORandom );
2014-01-22 16:31:33 +01:00
pTexture2->Release();
2014-02-07 15:52:07 +01:00
return Core::Init::Success;
}
2014-01-08 07:01:59 +01:00
2014-02-07 15:52:07 +01:00
Core::Init::State Resources::InitPasses()
{
2014-01-08 07:01:59 +01:00
////---------------- Geometry Pass Setup ----------------------------
2014-02-07 15:52:07 +01:00
Gather::Pass.Shaders.Pixel = GetShader::Pixel(L"Gather");
Gather::Pass.Shaders.Vertex = GetShader::Vertex(L"Gather");
D3D11_INPUT_ELEMENT_DESC indesc[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
2014-01-17 08:51:12 +01:00
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "BITANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 44, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "BONEINDEX", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 56, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "BONEWEIGHT", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 72, D3D11_INPUT_PER_VERTEX_DATA, 0 }
};
2014-02-07 15:52:07 +01:00
Shader::CreateInputLayout(indesc,7,GetShader::Vertex(L"Gather"),Gather::Pass.IAStage.Layout);
Gather::Pass.IAStage.Topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
Gather::Pass.CBuffers.Vertex.push_back(Gather::AnimationData);
Gather::Pass.CBuffers.Vertex.push_back(Gather::ModelData);
Gather::Pass.RenderStates.Rasterizer = RenderStates::rs;
Gather::Pass.RenderStates.SampleCount = 1;
Gather::Pass.RenderStates.SampleState = RenderStates::ss;
Gather::Pass.RenderStates.DepthStencil = RenderStates::dsState;
2014-02-07 11:09:59 +01:00
for(int i = 0; i<GBufferSize;++i)
{
2014-02-07 15:52:07 +01:00
Gather::Pass.RTV.push_back(GBufferRTV[i]);
}
2014-02-07 15:52:07 +01:00
Gather::Pass.depth = Core::depthStencil;
2014-01-08 07:01:59 +01:00
////---------------- Light Pass Setup ----------------------------
2014-02-07 15:52:07 +01:00
Light::Pass.Shaders.Compute = GetShader::Compute(L"LightPass");
for(int i = 0; i<LBufferSize;++i)
2014-01-08 07:01:59 +01:00
{
2014-02-07 15:52:07 +01:00
Light::Pass.UAV.Compute.push_back(LBufferUAV[i]);
2014-01-08 07:01:59 +01:00
}
2014-02-07 15:52:07 +01:00
for(int i = 0; i<GBufferSize;++i)
{
2014-02-07 15:52:07 +01:00
Light::Pass.SRV.Compute.push_back(GBufferSRV[i]);
}
2014-02-07 15:52:07 +01:00
Light::Pass.SRV.Compute.push_back(Core::depthStencilUAV);
Light::Pass.CBuffers.Compute.push_back(Light::LightConstantsData);
Light::Pass.SRV.Compute.push_back(Light::PointLightView);
Light::Pass.SRV.Compute.push_back(Light::SSAOKernel);
Light::Pass.SRV.Compute.push_back(Light::SSAORandom);
2014-01-08 07:01:59 +01:00
////---------------- Post Pass Setup ----------------------------
2014-02-07 16:51:35 +01:00
Post::Pass.Shaders.Compute = GetShader::Compute(L"PostPass");
2014-02-07 15:52:07 +01:00
for(int i = 0; i<LBufferSize;++i)
2014-01-08 07:01:59 +01:00
{
2014-02-07 16:51:35 +01:00
Post::Pass.SRV.Compute.push_back(LBufferSRV[i]);
2014-01-08 07:01:59 +01:00
}
2014-02-07 16:51:35 +01:00
Post::Pass.UAV.Compute.push_back(Core::backBufferUAV);
2014-02-10 01:03:10 +01:00
Post::Pass.CBuffers.Compute.push_back(Post::Data);
2014-02-07 11:09:59 +01:00
////---------------- GUI Pass Setup ----------------------------
2014-02-07 15:52:07 +01:00
Gui::Pass.Shaders.Vertex = GetShader::Vertex(L"2D");
Gui::Pass.Shaders.Pixel = GetShader::Pixel(L"2D");
Gui::Pass.Shaders.Geometry = GetShader::Geometry(L"2D");
Gui::Pass.RTV.push_back(GBufferRTV[2]);
2014-02-07 16:51:35 +01:00
Gui::Pass.CBuffers.Geometry.push_back(Gui::Data);
2014-02-07 11:09:59 +01:00
D3D11_INPUT_ELEMENT_DESC indesc2D[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
};
2014-02-07 15:52:07 +01:00
Shader::CreateInputLayout(indesc2D,1,GetShader::Vertex(L"2D"),Gui::Pass.IAStage.Layout);
Gui::Pass.IAStage.Topology = D3D_PRIMITIVE_TOPOLOGY_POINTLIST;
2014-02-07 11:09:59 +01:00
2014-02-07 15:52:07 +01:00
Gui::Pass.RenderStates.SampleCount = 1;
Gui::Pass.RenderStates.SampleState = RenderStates::ss;
2014-02-12 08:35:21 +01:00
Gui::Pass.RenderStates.BlendState = RenderStates::bs;
2014-02-07 11:09:59 +01:00
2014-02-07 13:46:55 +01:00
////---------------- Blur Pass Setup ----------------------------
2014-02-07 15:52:07 +01:00
Blur::HorPass.Shaders.Compute = GetShader::Compute(L"BlurHor");
Blur::VertPass.Shaders.Compute = GetShader::Compute(L"BlurVert");
2014-02-07 13:46:55 +01:00
//Taking the Ambient SRV from LBufferSRV and setting it as input texture
2014-02-07 15:52:07 +01:00
Blur::HorPass.SRV.Compute.push_back(LBufferSRV[2]);
2014-02-07 13:46:55 +01:00
//Output texture is the Blur UAV buffer
2014-02-07 15:52:07 +01:00
Blur::HorPass.UAV.Compute.push_back(Blur::BufferUAV);
2014-02-07 13:46:55 +01:00
//Taking the Blur SRV and setting it as input texture now
2014-02-07 15:52:07 +01:00
Blur::VertPass.SRV.Compute.push_back(Blur::BufferSRV);
2014-02-07 13:46:55 +01:00
//And the Ambient UAV is now the output texture
2014-02-07 15:52:07 +01:00
Blur::VertPass.UAV.Compute.push_back(LBufferUAV[2]);
2014-02-11 13:29:19 +01:00
////---------------- 2DText Pass Setup ----------------------------
Gui::Text::Pass.Shaders.Vertex = GetShader::Vertex(L"2DText");
Gui::Text::Pass.Shaders.Geometry = GetShader::Geometry(L"2DText");
Gui::Text::Pass.Shaders.Pixel = GetShader::Pixel(L"2D");
Gui::Text::Pass.IAStage.Topology = D3D11_PRIMITIVE_TOPOLOGY_POINTLIST;
D3D11_INPUT_ELEMENT_DESC Text2Ddesc[] =
{
{"Position",0, DXGI_FORMAT_R32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"Offset",0, DXGI_FORMAT_R32_SINT, 0, 4, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"CharOffset",0, DXGI_FORMAT_R32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0},
};
Shader::CreateInputLayout(Text2Ddesc,3, GetShader::Vertex(L"2DText") ,Gui::Text::Pass.IAStage.Layout);
Gui::Text::Pass.CBuffers.Geometry.push_back(Gui::Data);
Gui::Text::Pass.SRV.Pixel.push_back(Gui::Text::Font);
Gui::Text::Pass.RTV.push_back(GBufferRTV[2]);
Gui::Text::Pass.RenderStates.SampleCount = 1;
Gui::Text::Pass.RenderStates.SampleState = RenderStates::ss;
Gui::Text::Pass.RenderStates.BlendState = RenderStates::bs;
2014-02-07 15:52:07 +01:00
return Core::Init::Success;
}
Core::Init::State Resources::Init()
{
InitShaders();
InitBuffers();
InitRenderStates();
InitViews();
InitPasses();
2014-02-07 13:46:55 +01:00
return Core::Init::State::Success;
}
2014-02-07 15:52:07 +01:00
void Resources::Clean()
{
2014-02-07 15:52:07 +01:00
Gather::ModelData.~Buffer();
Gather::AnimationData.~Buffer();
Light::LightConstantsData.~Buffer();
Light::PointLightsData.~Buffer();
Gui::Data.~Buffer();
2014-02-11 13:29:19 +01:00
Gui::Text::Vertex.~Buffer();
2014-02-10 01:03:10 +01:00
Post::Data.~Buffer();
2014-02-07 15:52:07 +01:00
SAFE_RELEASE(Light::PointLightView);
SAFE_RELEASE(Light::SSAOKernel);
SAFE_RELEASE(Light::SSAORandom);
SAFE_RELEASE(Blur::BufferSRV);
SAFE_RELEASE(Blur::BufferUAV);
2014-02-07 13:46:55 +01:00
for(int i = 0; i< GBufferSize; ++i)
{
SAFE_RELEASE(GBufferRTV[i]);
SAFE_RELEASE(GBufferSRV[i]);
}
2014-01-08 07:01:59 +01:00
for(int i = 0; i< LBufferSize; ++i)
{
2014-01-08 07:01:59 +01:00
SAFE_RELEASE(LBufferUAV[i]);
SAFE_RELEASE(LBufferSRV[i]);
}
2014-02-07 15:52:07 +01:00
SAFE_RELEASE(Gather::Pass.IAStage.Layout);
2014-02-07 15:52:07 +01:00
SAFE_RELEASE(Gather::Pass.RenderStates.BlendState);
2014-02-07 15:52:07 +01:00
SAFE_RELEASE(Gather::Pass.RenderStates.DepthStencil);
2014-02-07 15:52:07 +01:00
SAFE_RELEASE(Gather::Pass.RenderStates.Rasterizer);
2014-02-07 15:52:07 +01:00
for(int i = 0; i < Gather::Pass.RenderStates.SampleCount; ++i)
{
2014-02-07 15:52:07 +01:00
SAFE_RELEASE(Gather::Pass.RenderStates.SampleState[i]);
}
2014-02-07 15:52:07 +01:00
SAFE_DELETE_ARRAY(Gather::Pass.RenderStates.SampleState);
2014-02-07 11:52:51 +01:00
2014-02-07 15:52:07 +01:00
SAFE_RELEASE(Gui::Pass.IAStage.Layout);
2014-02-11 13:29:19 +01:00
SAFE_RELEASE(Gui::Text::Pass.RenderStates.BlendState);
SAFE_RELEASE(Gui::Text::Pass.IAStage.Layout);
}
}
}
}