Fixes
This commit is contained in:
@ -37,6 +37,7 @@ namespace ia::iae
|
||||
SDL_GPUDevice *Renderer::s_gpuDevice{};
|
||||
|
||||
SDL_GPUTexture *Renderer::s_renderTargetSceneColor{};
|
||||
SDL_GPUTexture *Renderer::s_renderTargetSceneDepth{};
|
||||
SDL_GPUTexture *Renderer::s_renderTargetDebugDrawColor{};
|
||||
|
||||
Pipeline *Renderer::s_geometryPipeline{};
|
||||
@ -44,8 +45,6 @@ namespace ia::iae
|
||||
|
||||
Renderer::Geometry *Renderer::s_quadGeometry{};
|
||||
|
||||
Vector<Renderer::DrawCommand> Renderer::s_drawCommands;
|
||||
|
||||
VOID Renderer::Initialize()
|
||||
{
|
||||
if (!(s_gpuDevice = SDL_CreateGPUDevice(SDL_GPU_SHADERFORMAT_SPIRV, Engine::IsDebugMode(), nullptr)))
|
||||
@ -98,6 +97,14 @@ namespace ia::iae
|
||||
s_state.ColorTargetInfo.load_op = SDL_GPU_LOADOP_CLEAR;
|
||||
s_state.ColorTargetInfo.store_op = SDL_GPU_STOREOP_STORE;
|
||||
|
||||
s_state.DepthStencilTargetInfo.cycle = true;
|
||||
s_state.DepthStencilTargetInfo.clear_depth = 0;
|
||||
s_state.DepthStencilTargetInfo.clear_stencil = 0;
|
||||
s_state.DepthStencilTargetInfo.load_op = SDL_GPU_LOADOP_CLEAR;
|
||||
s_state.DepthStencilTargetInfo.store_op = SDL_GPU_STOREOP_STORE;
|
||||
s_state.DepthStencilTargetInfo.stencil_load_op = SDL_GPU_LOADOP_CLEAR;
|
||||
s_state.DepthStencilTargetInfo.stencil_store_op = SDL_GPU_STOREOP_STORE;
|
||||
|
||||
s_quadGeometry = CreateGeometry(
|
||||
{
|
||||
{glm::vec3{0, 1, 0}, glm::vec2{0, 1}, glm::vec4{1.0f, 1.0f, 1.0f, 1.0f}},
|
||||
@ -119,6 +126,7 @@ namespace ia::iae
|
||||
delete s_geometryPipeline;
|
||||
delete s_postprocessPipeline;
|
||||
|
||||
GPUResourceManager::DestroyTexture(s_renderTargetSceneDepth);
|
||||
GPUResourceManager::DestroyTexture(s_renderTargetSceneColor);
|
||||
GPUResourceManager::DestroyTexture(s_renderTargetDebugDrawColor);
|
||||
|
||||
@ -136,8 +144,9 @@ namespace ia::iae
|
||||
const auto clearColor = WorldManager::GetActiveScene()->BackgroundColor().GetAsFloatVec();
|
||||
s_state.ColorTargetInfo.clear_color = SDL_FColor{clearColor.x, clearColor.y, clearColor.z, 1.0f};
|
||||
s_state.ColorTargetInfo.texture = s_renderTargetSceneColor;
|
||||
s_state.DepthStencilTargetInfo.texture = s_renderTargetSceneDepth;
|
||||
s_state.ActiveRenderPass = SDL_BeginGPURenderPass(s_state.ActiveCommandBuffer, &s_state.ColorTargetInfo, 1,
|
||||
nullptr);
|
||||
&s_state.DepthStencilTargetInfo);
|
||||
|
||||
SDL_BindGPUGraphicsPipeline(s_state.ActiveRenderPass, s_geometryPipeline->GetHandle());
|
||||
SDL_PushGPUVertexUniformData(
|
||||
@ -191,11 +200,16 @@ namespace ia::iae
|
||||
s_screenWidth = newWidth;
|
||||
s_screenHeight = newHeight;
|
||||
|
||||
if (s_renderTargetSceneDepth)
|
||||
GPUResourceManager::DestroyTexture(s_renderTargetSceneDepth);
|
||||
if (s_renderTargetSceneColor)
|
||||
GPUResourceManager::DestroyTexture(s_renderTargetSceneColor);
|
||||
if (s_renderTargetDebugDrawColor)
|
||||
GPUResourceManager::DestroyTexture(s_renderTargetDebugDrawColor);
|
||||
|
||||
s_renderTargetSceneDepth =
|
||||
GPUResourceManager::CreateTexture(SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET, s_screenWidth, s_screenHeight,
|
||||
nullptr, SDL_GPU_TEXTUREFORMAT_D16_UNORM);
|
||||
s_renderTargetSceneColor = GPUResourceManager::CreateTexture(
|
||||
SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER, s_screenWidth, s_screenHeight, nullptr,
|
||||
SDL_GetGPUSwapchainTextureFormat(s_gpuDevice, g_windowHandle));
|
||||
|
||||
@ -52,16 +52,11 @@ namespace ia::iae
|
||||
SDL_GPURenderPass* ActiveRenderPass{};
|
||||
SDL_GPUCommandBuffer* ActiveCommandBuffer{};
|
||||
SDL_GPUColorTargetInfo ColorTargetInfo{};
|
||||
SDL_GPUDepthStencilTargetInfo DepthStencilTargetInfo{};
|
||||
|
||||
class CameraComponent *ActiveCamera{};
|
||||
};
|
||||
|
||||
struct DrawCommand
|
||||
{
|
||||
State DrawState{};
|
||||
Geometry* GeometryHandle{};
|
||||
};
|
||||
|
||||
public:
|
||||
STATIC VOID Initialize();
|
||||
STATIC VOID Terminate();
|
||||
@ -92,11 +87,11 @@ namespace ia::iae
|
||||
STATIC INT32 s_screenHeight;
|
||||
STATIC SDL_GPUDevice *s_gpuDevice;
|
||||
STATIC SDL_GPUTexture *s_renderTargetSceneColor;
|
||||
STATIC SDL_GPUTexture *s_renderTargetSceneDepth;
|
||||
STATIC SDL_GPUTexture *s_renderTargetDebugDrawColor;
|
||||
STATIC Pipeline* s_geometryPipeline;
|
||||
STATIC Pipeline* s_postprocessPipeline;
|
||||
STATIC Geometry* s_quadGeometry;
|
||||
STATIC Vector<DrawCommand> s_drawCommands;
|
||||
|
||||
friend class Engine;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user