Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- //
- // RenderPassTextured.cpp
- //
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- // Header section
- #include "RenderPassTextured.h"
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- // Declaration section
- using namespace Engine;
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- // Definition section
- /// <summary>
- /// Constructor
- ///
- /// Initializes textured render pass
- /// </summary>
- /// <param name="log">Pointer to logging system</param>
- /// <param name="renderer">Pointer to renderer</param>
- /// <param name="assetManager">Pointer to asset manager</param>
- /// <param name="width">Width of output buffers</param>
- /// <param name="height">Height of output buffers</param>
- /// <param name="samples">MSAA Samples of output buffers</param>
- RenderPassTextured::RenderPassTextured(Log* log, D3DRenderer* renderer, AssetManager* assetManager, unsigned int width, unsigned int height, unsigned int samples) :
- RenderPassGeometry(log, renderer, assetManager, width, height)
- {
- mSamples = samples;
- Setup();
- Init();
- mColorBuffer = new Engine::ColorBuffer(renderer, 0.0f, 0.0f, 0.0f, 1.0f);
- mColorBuffer->Create(mWidth, mHeight, 1, Engine::Graphics::Format::RGBA16F, false, mSamples, 0);
- mDepthBuffer = new Engine::DepthBuffer(mRenderer, 1.0f, 0);
- mDepthBuffer->Create(mWidth, mHeight, Engine::Graphics::Format::D32F, false, mSamples, 0);
- mCameraBuffer = new Engine::GpuMappedBuffer();
- mCameraBuffer->Init(mRenderer, 64, sizeof(float));
- mCameraBufferPtr = mCameraBuffer->Map();
- }
- /// <summary>
- /// Setup root signature and shader (+ manager node) for mesh shading approach
- /// </summary>
- void RenderPassTextured::SetupMeshShading()
- {
- mRootSignature = new Engine::RootSignature(mRenderer->GetDevice(), 11, 1);
- (*mRootSignature)[0].InitAsSRVBuffer(0);
- (*mRootSignature)[1].InitAsSRVBuffer(1);
- (*mRootSignature)[2].InitAsSRVBuffer(2);
- (*mRootSignature)[3].InitAsSRVBuffer(3);
- (*mRootSignature)[4].InitAsSRVBuffer(4);
- (*mRootSignature)[5].InitAsConstants(0, 2);
- (*mRootSignature)[6].InitAsDescriptorTable(1);
- (*mRootSignature)[6].SetTableRange(0, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 5, 1);
- (*mRootSignature)[7].InitAsConstantBuffer(1);
- (*mRootSignature)[8].InitAsDescriptorTable(1);
- (*mRootSignature)[8].SetTableRange(0, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 6, 1);
- (*mRootSignature)[9].InitAsDescriptorTable(1);
- (*mRootSignature)[9].SetTableRange(0, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 7, (unsigned int)mRenderer->HeapArray(mRenderer->HEAP_ARRAY_TEXTURES)->GetSize());
- (*mRootSignature)[10].InitAsDescriptorTable(1);
- (*mRootSignature)[10].SetTableRange(0, D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 0, 1);
- mRootSignature->InitStaticSampler(0, Engine::Sampler::CreateSamplerD3D(Engine::Sampler::Filter::ANISOTROPIC,
- Engine::Sampler::Address::WRAP,
- Engine::Sampler::Address::WRAP,
- Engine::Sampler::Address::WRAP,
- 0.0f,
- 16,
- Engine::Sampler::ComparisonFunc::NEVER,
- 1.0f, 1.0f, 1.0f, 1.0f,
- 0.0f,
- 32.0f));
- mRootSignature->Finalize(D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT);
- mShader = (Engine::Manager<Engine::Shader>::Node*)mAssetManager->Load(
- Engine::ShaderHelper::Serialize("../Data/Shaders/Geometry/Textured.hlsl",
- mRenderer->mAmplificationShaders ?
- std::vector<ShaderEntryPoint>
- {
- Engine::ShaderEntryPoint(Engine::ShaderType::AMPLIFICATION_SHADER, L"AS"),
- Engine::ShaderEntryPoint(Engine::ShaderType::MESH_SHADER, L"MS"),
- Engine::ShaderEntryPoint(Engine::ShaderType::PIXEL_SHADER, L"PS")
- } :
- std::vector<ShaderEntryPoint>
- {
- Engine::ShaderEntryPoint(Engine::ShaderType::MESH_SHADER, L"MS"),
- Engine::ShaderEntryPoint(Engine::ShaderType::PIXEL_SHADER, L"PS")
- },
- std::vector<ShaderDefine>
- {
- Engine::ShaderDefine(L"USE_AMPLIFICATION_SHADERS", mRenderer->mAmplificationShaders ? std::to_wstring(1) : std::to_wstring(0)),
- Engine::ShaderDefine(L"USE_MESH_SHADERS", std::to_wstring(1)),
- Engine::ShaderDefine(L"VERTEX_SIZE", std::to_wstring(16)),
- Engine::ShaderDefine(L"VERTEX_POSITION_OFFSET", std::to_wstring(0)),
- Engine::ShaderDefine(L"VERTEX_TEXCOORD_OFFSET", std::to_wstring(12)),
- Engine::ShaderDefine(L"VERTEX_NORMAL_OFFSET", std::to_wstring(3)),
- Engine::ShaderDefine(L"VERTEX_TANGENT_OFFSET", std::to_wstring(6)),
- Engine::ShaderDefine(L"VERTEX_BITANGENT_OFFSET", std::to_wstring(9)),
- #ifdef USE_QUANTIZED_MESHLET_INDICES
- Engine::ShaderDefine(L"USE_QUANTIZED_MESHLET_INDICES", L"1"),
- #else
- Engine::ShaderDefine(L"USE_QUANTIZED_MESHLET_INDICES", L"0"),
- #endif
- Engine::ShaderDefine(L"DEBUG_CLUSTERS", L"0")
- }),
- false,
- false);
- mAssetManager->RegisterShaderMapping(mShader->mName, this);
- }
- /// <summary>
- /// Setup root signature and shader (+ manager node) for vertex shading approach
- /// </summary>
- void RenderPassTextured::SetupVertexShading()
- {
- mRootSignature = new Engine::RootSignature(mRenderer->GetDevice(), 5, 1);
- (*mRootSignature)[0].InitAsConstants(0, 1);
- (*mRootSignature)[1].InitAsDescriptorTable(1);
- (*mRootSignature)[1].SetTableRange(0, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 1);
- (*mRootSignature)[2].InitAsConstantBuffer(1);
- (*mRootSignature)[3].InitAsDescriptorTable(1);
- (*mRootSignature)[3].SetTableRange(0, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 1, 1);
- (*mRootSignature)[4].InitAsDescriptorTable(1);
- (*mRootSignature)[4].SetTableRange(0, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 2, (unsigned int)mRenderer->HeapArray(mRenderer->HEAP_ARRAY_TEXTURES)->GetSize());
- mRootSignature->InitStaticSampler(0, Engine::Sampler::CreateSamplerD3D(Engine::Sampler::Filter::ANISOTROPIC,
- Engine::Sampler::Address::WRAP,
- Engine::Sampler::Address::WRAP,
- Engine::Sampler::Address::WRAP,
- 0.0f,
- 16,
- Engine::Sampler::ComparisonFunc::NEVER,
- 1.0f, 1.0f, 1.0f, 1.0f,
- 0.0f,
- 32.0f));
- mRootSignature->Finalize(D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT);
- mShader = (Engine::Manager<Engine::Shader>::Node*)mAssetManager->Load(
- Engine::ShaderHelper::Serialize("../Data/Shaders/Geometry/Textured.hlsl",
- std::vector<ShaderEntryPoint>
- {
- Engine::ShaderEntryPoint(Engine::ShaderType::VERTEX_SHADER, L"VS"),
- Engine::ShaderEntryPoint(Engine::ShaderType::PIXEL_SHADER, L"PS")
- },
- std::vector<ShaderDefine>()),
- false,
- false);
- mAssetManager->RegisterShaderMapping(mShader->mName, this);
- }
- /// <summary>
- /// Initialize shader and pipeline state for mesh shading approach
- /// </summary>
- void RenderPassTextured::InitMeshShading()
- {
- Engine::DepthStencilState dsState = Engine::DepthStencilState(true);
- std::vector<Engine::Graphics::Format> rtvFormats;
- rtvFormats.push_back(Engine::Graphics::Format::RGBA16F);
- if (mPipelineState != nullptr)
- {
- delete mPipelineState;
- mPipelineState = nullptr;
- }
- mPipelineState = new Engine::PipelineState(mRenderer->GetDevice6(),
- mRootSignature,
- mShader->Get(),
- Engine::BlendState::CreateStateD3D(true),
- Engine::RasterizerState::CreateStateD3D(),
- &dsState,
- rtvFormats,
- Engine::Graphics::Format::D32F,
- mSamples,
- 0);
- }
- /// <summary>
- /// Initialize shader and pipeline state for vertex shading approach
- /// </summary>
- void RenderPassTextured::InitVertexShading()
- {
- Engine::InputLayout inputLayout = Engine::InputLayout();
- inputLayout.AddAttribute(Engine::InputLayout::Attribute("POSITION", 0, Engine::Graphics::Format::RGB32F, 0, 0, Engine::InputLayout::Classification::PER_VERTEX, 0));
- inputLayout.AddAttribute(Engine::InputLayout::Attribute("NORMAL", 0, Engine::Graphics::Format::RGB32F, 0, 12, Engine::InputLayout::Classification::PER_VERTEX, 0));
- inputLayout.AddAttribute(Engine::InputLayout::Attribute("TEXCOORD", 2, Engine::Graphics::Format::RGB32F, 0, 24, Engine::InputLayout::Classification::PER_VERTEX, 0));
- inputLayout.AddAttribute(Engine::InputLayout::Attribute("TEXCOORD", 3, Engine::Graphics::Format::RGB32F, 0, 36, Engine::InputLayout::Classification::PER_VERTEX, 0));
- inputLayout.AddAttribute(Engine::InputLayout::Attribute("TEXCOORD", 0, Engine::Graphics::Format::RG32F, 0, 48, Engine::InputLayout::Classification::PER_VERTEX, 0));
- inputLayout.AddAttribute(Engine::InputLayout::Attribute("TEXCOORD", 1, Engine::Graphics::Format::RG32F, 0, 56, Engine::InputLayout::Classification::PER_VERTEX, 0));
- Engine::DepthStencilState dsState = Engine::DepthStencilState(true);
- std::vector<Engine::Graphics::Format> rtvFormats;
- rtvFormats.push_back(Engine::Graphics::Format::RGBA16F);
- if (mPipelineState != nullptr)
- {
- delete mPipelineState;
- mPipelineState = nullptr;
- }
- mPipelineState = new Engine::PipelineState(mRenderer->GetDevice(),
- mRootSignature,
- mShader->Get(),
- Engine::BlendState::CreateStateD3D(true),
- Engine::RasterizerState::CreateStateD3D(),
- &dsState,
- &inputLayout,
- Engine::PipelineState::PrimitiveType::TRIANGLE,
- rtvFormats,
- Engine::Graphics::Format::D32F,
- mSamples,
- 0);
- }
- /// <summary>
- /// Destructor
- ///
- /// Cleans up created renderer objects and frees used memory
- /// </summary>
- RenderPassTextured::~RenderPassTextured()
- {
- delete mRootSignature;
- mRootSignature = nullptr;
- delete mPipelineState;
- mPipelineState = nullptr;
- delete mDepthBuffer;
- mDepthBuffer = nullptr;
- delete mColorBuffer;
- mColorBuffer = nullptr;
- mCameraBuffer->Unmap();
- delete mCameraBuffer;
- }
- static bool run = false;
- /// <summary>
- /// Enqueue render pass for processing in graphics context
- /// </summary>
- /// <param name="camera">Camera view for rendering</param>
- /// <param name="heap">Memory heap</param>
- /// <param name="context">Graphics context</param>
- /// <param name="renderNodes">Render nodes list to render</param>
- void RenderPassTextured::Process(Engine::Camera* camera, Engine::DescriptorHeap* heap, Engine::GraphicsContext* context, Engine::RenderNodeList* renderNodes, Engine::StructuredBuffer* materials, Engine::Culling* culling)
- {
- if (camera && renderNodes->GetIndirectDrawCount() > 0)
- {
- run = true;
- Engine::mat4 viewMatrix = camera->GetViewMatrix();
- Engine::mat4 projectionMatrix = camera->GetProjectionMatrix();
- Engine::Frustum* frustum = camera->GetFrustum();
- struct DataBuffer
- {
- Engine::mat4 viewMatrix;
- Engine::mat4 projectionMatrix;
- Engine::float4 frustumPlanes[6];
- Engine::float4 viewPosition;
- unsigned int pad[4];
- };
- mat4 cullViewMatrix = inverse(viewMatrix);
- float* cullViewMatrixPtr = (float*)&cullViewMatrix;
- DataBuffer constBuffer;
- constBuffer.viewMatrix = viewMatrix;
- constBuffer.projectionMatrix = projectionMatrix;
- constBuffer.frustumPlanes[0] = frustum->GetPlane(0).mEquation;
- constBuffer.frustumPlanes[1] = frustum->GetPlane(1).mEquation;
- constBuffer.frustumPlanes[2] = frustum->GetPlane(2).mEquation;
- constBuffer.frustumPlanes[3] = frustum->GetPlane(3).mEquation;
- constBuffer.frustumPlanes[4] = frustum->GetPlane(4).mEquation;
- constBuffer.frustumPlanes[5] = frustum->GetPlane(5).mEquation;
- constBuffer.viewPosition = camera->GetPosition();
- memcpy(mCameraBufferPtr, &constBuffer, sizeof(DataBuffer));
- context->SetPipelineState(mPipelineState);
- context->SetRootSignature(mRootSignature);
- context->SetDescriptorHeap(Engine::DescriptorHeap::CBV_SRV_UAV, heap);
- context->SetViewport(0.0f, 0.0f, (float)mWidth, (float)mHeight);
- context->SetScissorRect(0.0f, 0.0f, (float)mWidth, (float)mHeight);
- context->TransitionResource(mDebugBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, false);
- context->TransitionResource(mColorBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET, false);
- context->TransitionResource(mDepthBuffer, D3D12_RESOURCE_STATE_DEPTH_WRITE, true);
- context->SetRenderTargets(mColorBuffer, mDepthBuffer);
- context->ClearColor(mColorBuffer, 0.0f, 0.0f, 0.0f, 1.0f);
- context->ClearDepth(mDepthBuffer, 1.0f, 0);
- context->SetPrimitiveTopology(Engine::Graphics::TRIANGLELIST);
- if (mRenderer->mMeshShaders)
- {
- context->SetDescriptorTable(6, renderNodes->GetBuffer()->GetSRV());
- context->SetConstantBuffer(7, mCameraBuffer->GetGpuVirtualAddress());
- context->SetDescriptorTable(8, materials->GetSRV());
- context->SetDescriptorTable(9, mRenderer->HeapArray(mRenderer->HEAP_ARRAY_TEXTURES)->Get(0));
- context->SetDescriptorTable(10, mDebugBuffer->GetUAV());
- }
- else
- {
- context->SetDescriptorTable(1, renderNodes->GetBuffer()->GetSRV());
- context->SetConstantBuffer(2, mCameraBuffer->GetGpuVirtualAddress());
- context->SetDescriptorTable(3, materials->GetSRV());
- context->SetDescriptorTable(4, mRenderer->HeapArray(mRenderer->HEAP_ARRAY_TEXTURES)->Get(0));
- }
- if (culling != nullptr)
- {
- context->ExecuteIndirect(*(renderNodes->GetCommandSignature(0)), *(culling->GetResultsArgsBuffer()), 0, renderNodes->GetIndirectDrawCount(), &(culling->GetResultsArgsBuffer()->GetCounterBuffer()), 0);
- }
- else
- {
- context->ExecuteIndirect(*(renderNodes->GetCommandSignature(0)), *(renderNodes->GetIndirectArgsBuffer()), 0, renderNodes->GetIndirectDrawCount());
- }
- context->TransitionResource(mColorBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, false);
- context->TransitionResource(mDepthBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, true);
- }
- }
- /// <summary>^
- /// Resize output buffers of textured render pass
- /// </summary>
- /// <param name="width">New width</param>
- /// <param name="height">New height</param>
- void RenderPassTextured::Resize(unsigned int width, unsigned int height)
- {
- mWidth = width;
- mHeight = height;
- mColorBuffer->Release();
- mColorBuffer->Create(mWidth, mHeight, 1, Engine::Graphics::Format::RGBA16F, false, mSamples, 0);
- mDepthBuffer->Release();
- mDepthBuffer->Create(mWidth, mHeight, Engine::Graphics::Format::D32F, false, mSamples, 0);
- }
Advertisement
Comments
-
- ⭐ Changelly Profit Exploit Documentation ⭐
- https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=juowjsyxos
- This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
- The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
- Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment