Added a DX12/DXIL variant of the clear_swapchain program.
This commit is contained in:
parent
febb71f2c1
commit
e9ddad2dfb
30
private/sdl_gpu_test/0_clear_swapchain_dxil/app.cpp
Normal file
30
private/sdl_gpu_test/0_clear_swapchain_dxil/app.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
#include "./app.hpp"
|
||||
|
||||
namespace sdl_gpu_test
|
||||
{
|
||||
void ClearSwapchainDXILApp::init(const AppInitArgs& args)
|
||||
{
|
||||
mOptions.shaderFormats = {.dxil = true};
|
||||
Application::init(args);
|
||||
}
|
||||
|
||||
void ClearSwapchainDXILApp::update(const AppUpdateArgs& args)
|
||||
{
|
||||
Application::update(args);
|
||||
|
||||
sdlpp::GPUCommandBuffer cmdBuffer = mDevice.acquireCommandBuffer();
|
||||
Uint32 swapchainWidth = 0, swapchainHeight = 0;
|
||||
sdlpp::GPUTexture swapchainTexture = cmdBuffer.acquireSwapchainTexture(mWindow, swapchainWidth, swapchainHeight);
|
||||
std::array colorTargets = {sdlpp::GPUColorTargetInfo{
|
||||
.texture = swapchainTexture,
|
||||
.clearColor = {.r = 1.f, .g = 0.f, .b = 0.f, .a = 1.f},
|
||||
.loadOp = sdlpp::GPULoadOp::CLEAR,
|
||||
}};
|
||||
sdlpp::GPURenderPass renderPass = cmdBuffer.beginRenderPass({
|
||||
.colorTargetInfos = colorTargets
|
||||
});
|
||||
renderPass.end();
|
||||
cmdBuffer.submit();
|
||||
}
|
||||
}
|
19
private/sdl_gpu_test/0_clear_swapchain_dxil/app.hpp
Normal file
19
private/sdl_gpu_test/0_clear_swapchain_dxil/app.hpp
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(SDL_GPU_TEST_PRIVATE_SDL_GPU_TEST_0_CLEAR_SWAPCHAIN_DXIL_APP_HPP_INCLUDED)
|
||||
#define SDL_GPU_TEST_PRIVATE_SDL_GPU_TEST_0_CLEAR_SWAPCHAIN_DXIL_APP_HPP_INCLUDED 1
|
||||
|
||||
#include "../application.hpp"
|
||||
|
||||
namespace sdl_gpu_test
|
||||
{
|
||||
class ClearSwapchainDXILApp : public Application
|
||||
{
|
||||
public:
|
||||
void init(const AppInitArgs& args) override;
|
||||
void update(const AppUpdateArgs& args) override;
|
||||
};
|
||||
} // namespace sdl_gpu_test
|
||||
|
||||
#endif // !defined(SDL_GPU_TEST_PRIVATE_SDL_GPU_TEST_0_CLEAR_SWAPCHAIN_DXIL_APP_HPP_INCLUDED)
|
@ -20,7 +20,7 @@ void Application::init(const AppInitArgs& args)
|
||||
});
|
||||
|
||||
mDevice.create({
|
||||
.formatFlags{.spirv = true},
|
||||
.formatFlags = mOptions.shaderFormats,
|
||||
.debugMode = true
|
||||
});
|
||||
mDevice.claimWindow(mWindow);
|
||||
|
@ -26,6 +26,11 @@ struct AppCleanupArgs
|
||||
|
||||
};
|
||||
|
||||
struct AppOptions
|
||||
{
|
||||
sdlpp::GPUShaderFormatFlags shaderFormats = {.spirv = true};
|
||||
};
|
||||
|
||||
struct AppUpdateArgs
|
||||
{
|
||||
float secondsSinceStart = 0.f;
|
||||
@ -39,6 +44,7 @@ protected:
|
||||
sdlpp::GPUDevice mDevice;
|
||||
mijin::StackedFileSystemAdapter mFileSystem;
|
||||
mijin::SimpleTaskLoop mTaskLoop;
|
||||
AppOptions mOptions;
|
||||
bool mRunning = true;
|
||||
public:
|
||||
virtual ~Application() noexcept = default;
|
||||
|
Loading…
x
Reference in New Issue
Block a user