Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Do changes for Shader Passes in custom_material_resource #604

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions rootex/core/renderer/rendering_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,39 @@ void RenderingDevice::createOffScreenViews(int width, int height)
GFX_ERR_CHECK(m_Device->CreateShaderResourceView(m_OffScreenTexture.Get(), &shaderResourceViewDesc, &m_OffScreenSRV));
}

void RenderingDevice::createShaderPasses(int width, int height)
{
D3D11_TEXTURE2D_DESC bufferTexture;
ZeroMemory(&bufferTexture, sizeof(bufferTexture));
bufferTexture.Width = width;
bufferTexture.Height = height;
bufferTexture.MipLevels = 1;
bufferTexture.ArraySize = 1;
bufferTexture.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
bufferTexture.SampleDesc.Count = 1;
bufferTexture.Usage = D3D11_USAGE_DEFAULT;
bufferTexture.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
bufferTexture.CPUAccessFlags = 0;
bufferTexture.MiscFlags = 0;

GFX_ERR_CHECK(m_DeviceBg->CreateTexture2D(&bufferTexture, NULL, &m_ShaderPass));

D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewBuffer;
renderTargetViewBuffer.Format = bufferTexture.Format;
renderTargetViewBuffer.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
renderTargetViewBuffer.Texture2D.MipSlice = 0;
//enable a scene to be rendered to a temporary intermediate buffer, rather than to the back buffer to be rendered to the screen
GFX_ERR_CHECK(m_DeviceBg->CreateRenderTargetView(m_ShaderPass.Get(), &renderTargetViewBuffer, &m_ShaderPassRTV));

D3D11_SHADER_RESOURCE_VIEW_DESC shaderResourceViewBuffer;
shaderResourceViewBuffer.Format = bufferTexture.Format;
shaderResourceViewBuffer.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
shaderResourceViewBuffer.Texture2D.MostDetailedMip = 0;
shaderResourceViewBuffer.Texture2D.MipLevels = 1;
//typically wrap textures in a format that the shaders can access them
GFX_ERR_CHECK(m_DeviceBg->CreateShaderResourceView(m_ShaderPass.Get(), &shaderResourceViewBuffer, &m_ShaderPassSRV));
}

void RenderingDevice::createSwapChainAndRTVs(int width, int height, const HWND& hWnd)
{
DXGI_SWAP_CHAIN_DESC sd = { 0 };
Expand Down
6 changes: 6 additions & 0 deletions rootex/core/renderer/rendering_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class RenderingDevice
Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_OffScreenRTV;
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_OffScreenSRV;

Microsoft::WRL::ComPtr<ID3D11Device> m_DeviceBg;
Microsoft::WRL::ComPtr<ID3D11Texture2D> m_ShaderPass;
Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_ShaderPassRTV;
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_ShaderPassSRV;

Microsoft::WRL::ComPtr<ID3D11DepthStencilState> m_DSState;
UINT m_StencilRef;
Microsoft::WRL::ComPtr<ID3D11DepthStencilState> m_SkyDSState;
Expand Down Expand Up @@ -85,6 +90,7 @@ class RenderingDevice
static RenderingDevice* GetSingleton();
void initialize(HWND hWnd, int width, int height);
void createOffScreenViews(int width, int height);
void createShaderPasses(int width, int height);
/// Create resources which depend on window height and width
void createSwapChainAndRTVs(int width, int height, const HWND& hWnd);
void setScreenState(bool fullscreen);
Expand Down
Loading