This commit is contained in:
Isuru Samarathunga
2025-10-16 22:59:03 +05:30
parent 160bf65a1f
commit 2062c35fde
4 changed files with 18 additions and 21 deletions

View File

@ -37,7 +37,6 @@ namespace ia::iae
SDL_GPUDevice *Renderer::s_gpuDevice{}; SDL_GPUDevice *Renderer::s_gpuDevice{};
SDL_GPUTexture *Renderer::s_renderTargetSceneColor{}; SDL_GPUTexture *Renderer::s_renderTargetSceneColor{};
SDL_GPUTexture *Renderer::s_renderTargetSceneDepth{};
SDL_GPUTexture *Renderer::s_renderTargetDebugDrawColor{}; SDL_GPUTexture *Renderer::s_renderTargetDebugDrawColor{};
Pipeline *Renderer::s_geometryPipeline{}; Pipeline *Renderer::s_geometryPipeline{};
@ -45,6 +44,8 @@ namespace ia::iae
Renderer::Geometry *Renderer::s_quadGeometry{}; Renderer::Geometry *Renderer::s_quadGeometry{};
Vector<Renderer::DrawCommand> Renderer::s_drawCommands;
VOID Renderer::Initialize() VOID Renderer::Initialize()
{ {
if (!(s_gpuDevice = SDL_CreateGPUDevice(SDL_GPU_SHADERFORMAT_SPIRV, Engine::IsDebugMode(), nullptr))) if (!(s_gpuDevice = SDL_CreateGPUDevice(SDL_GPU_SHADERFORMAT_SPIRV, Engine::IsDebugMode(), nullptr)))
@ -97,14 +98,6 @@ namespace ia::iae
s_state.ColorTargetInfo.load_op = SDL_GPU_LOADOP_CLEAR; s_state.ColorTargetInfo.load_op = SDL_GPU_LOADOP_CLEAR;
s_state.ColorTargetInfo.store_op = SDL_GPU_STOREOP_STORE; 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( s_quadGeometry = CreateGeometry(
{ {
{glm::vec3{0, 1, 0}, glm::vec2{0, 1}, glm::vec4{1.0f, 1.0f, 1.0f, 1.0f}}, {glm::vec3{0, 1, 0}, glm::vec2{0, 1}, glm::vec4{1.0f, 1.0f, 1.0f, 1.0f}},
@ -126,7 +119,6 @@ namespace ia::iae
delete s_geometryPipeline; delete s_geometryPipeline;
delete s_postprocessPipeline; delete s_postprocessPipeline;
GPUResourceManager::DestroyTexture(s_renderTargetSceneDepth);
GPUResourceManager::DestroyTexture(s_renderTargetSceneColor); GPUResourceManager::DestroyTexture(s_renderTargetSceneColor);
GPUResourceManager::DestroyTexture(s_renderTargetDebugDrawColor); GPUResourceManager::DestroyTexture(s_renderTargetDebugDrawColor);
@ -144,9 +136,8 @@ namespace ia::iae
const auto clearColor = WorldManager::GetActiveScene()->BackgroundColor().GetAsFloatVec(); 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.clear_color = SDL_FColor{clearColor.x, clearColor.y, clearColor.z, 1.0f};
s_state.ColorTargetInfo.texture = s_renderTargetSceneColor; s_state.ColorTargetInfo.texture = s_renderTargetSceneColor;
s_state.DepthStencilTargetInfo.texture = s_renderTargetSceneDepth;
s_state.ActiveRenderPass = SDL_BeginGPURenderPass(s_state.ActiveCommandBuffer, &s_state.ColorTargetInfo, 1, s_state.ActiveRenderPass = SDL_BeginGPURenderPass(s_state.ActiveCommandBuffer, &s_state.ColorTargetInfo, 1,
&s_state.DepthStencilTargetInfo); nullptr);
SDL_BindGPUGraphicsPipeline(s_state.ActiveRenderPass, s_geometryPipeline->GetHandle()); SDL_BindGPUGraphicsPipeline(s_state.ActiveRenderPass, s_geometryPipeline->GetHandle());
SDL_PushGPUVertexUniformData( SDL_PushGPUVertexUniformData(
@ -200,16 +191,11 @@ namespace ia::iae
s_screenWidth = newWidth; s_screenWidth = newWidth;
s_screenHeight = newHeight; s_screenHeight = newHeight;
if (s_renderTargetSceneDepth)
GPUResourceManager::DestroyTexture(s_renderTargetSceneDepth);
if (s_renderTargetSceneColor) if (s_renderTargetSceneColor)
GPUResourceManager::DestroyTexture(s_renderTargetSceneColor); GPUResourceManager::DestroyTexture(s_renderTargetSceneColor);
if (s_renderTargetDebugDrawColor) if (s_renderTargetDebugDrawColor)
GPUResourceManager::DestroyTexture(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( s_renderTargetSceneColor = GPUResourceManager::CreateTexture(
SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER, s_screenWidth, s_screenHeight, nullptr, SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER, s_screenWidth, s_screenHeight, nullptr,
SDL_GetGPUSwapchainTextureFormat(s_gpuDevice, g_windowHandle)); SDL_GetGPUSwapchainTextureFormat(s_gpuDevice, g_windowHandle));

View File

@ -52,11 +52,16 @@ namespace ia::iae
SDL_GPURenderPass* ActiveRenderPass{}; SDL_GPURenderPass* ActiveRenderPass{};
SDL_GPUCommandBuffer* ActiveCommandBuffer{}; SDL_GPUCommandBuffer* ActiveCommandBuffer{};
SDL_GPUColorTargetInfo ColorTargetInfo{}; SDL_GPUColorTargetInfo ColorTargetInfo{};
SDL_GPUDepthStencilTargetInfo DepthStencilTargetInfo{};
class CameraComponent *ActiveCamera{}; class CameraComponent *ActiveCamera{};
}; };
struct DrawCommand
{
State DrawState{};
Geometry* GeometryHandle{};
};
public: public:
STATIC VOID Initialize(); STATIC VOID Initialize();
STATIC VOID Terminate(); STATIC VOID Terminate();
@ -87,11 +92,11 @@ namespace ia::iae
STATIC INT32 s_screenHeight; STATIC INT32 s_screenHeight;
STATIC SDL_GPUDevice *s_gpuDevice; STATIC SDL_GPUDevice *s_gpuDevice;
STATIC SDL_GPUTexture *s_renderTargetSceneColor; STATIC SDL_GPUTexture *s_renderTargetSceneColor;
STATIC SDL_GPUTexture *s_renderTargetSceneDepth;
STATIC SDL_GPUTexture *s_renderTargetDebugDrawColor; STATIC SDL_GPUTexture *s_renderTargetDebugDrawColor;
STATIC Pipeline* s_geometryPipeline; STATIC Pipeline* s_geometryPipeline;
STATIC Pipeline* s_postprocessPipeline; STATIC Pipeline* s_postprocessPipeline;
STATIC Geometry* s_quadGeometry; STATIC Geometry* s_quadGeometry;
STATIC Vector<DrawCommand> s_drawCommands;
friend class Engine; friend class Engine;
}; };

View File

@ -1 +1,7 @@
cmake -G Ninja -S . -B ./build-android -DCMAKE_TOOLCHAIN_FILE="%NDK_PATH%\build\cmake\android.toolchain.cmake" -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-35 -DCMAKE_BUILD_TYPE=Debug setlocal
SET PATH=%PATH%;./Tools
cmake -G Ninja -S . -B ./build-android-x64 -DCMAKE_TOOLCHAIN_FILE="Android/android-ndk-r27d/build/cmake/android.toolchain.cmake" -DANDROID_ABI=x86_64 -DANDROID_PLATFORM=android-35 -DCMAKE_BUILD_TYPE=Debug
cmake -G Ninja -S . -B ./build-android-armv8 -DCMAKE_TOOLCHAIN_FILE="Android/android-ndk-r27d/build/cmake/android.toolchain.cmake" -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-35 -DCMAKE_BUILD_TYPE=Debug
cmake --build ./build-android-x64
cmake --build ./build-android-armv8

2
Vendor/IACore vendored