GPUDevice: Add ExecuteAndWaitForGPUIdle()

This commit is contained in:
Stenzek 2024-07-04 21:54:19 +10:00
parent 9fcc98a60a
commit 3749b812a3
No known key found for this signature in database
11 changed files with 46 additions and 0 deletions

View file

@ -466,6 +466,11 @@ std::string D3D11Device::GetDriverInfo() const
return ret;
}
void D3D11Device::ExecuteAndWaitForGPUIdle()
{
m_context->Flush();
}
bool D3D11Device::CreateBuffers()
{
if (!m_vertex_buffer.Create(D3D11_BIND_VERTEX_BUFFER, VERTEX_BUFFER_SIZE, VERTEX_BUFFER_SIZE) ||

View file

@ -47,6 +47,8 @@ public:
std::string GetDriverInfo() const override;
void ExecuteAndWaitForGPUIdle() override;
std::unique_ptr<GPUTexture> CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples,
GPUTexture::Type type, GPUTexture::Format format,
const void* data = nullptr, u32 data_stride = 0) override;

View file

@ -638,6 +638,14 @@ void D3D12Device::WaitForGPUIdle()
}
}
void D3D12Device::ExecuteAndWaitForGPUIdle()
{
if (InRenderPass())
EndRenderPass();
SubmitCommandList(true);
}
bool D3D12Device::CreateTimestampQuery()
{
constexpr u32 QUERY_COUNT = NUM_TIMESTAMP_QUERIES_PER_CMDLIST * NUM_COMMAND_LISTS;

View file

@ -68,6 +68,8 @@ public:
std::string GetDriverInfo() const override;
void ExecuteAndWaitForGPUIdle() override;
std::unique_ptr<GPUTexture> CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples,
GPUTexture::Type type, GPUTexture::Format format,
const void* data = nullptr, u32 data_stride = 0) override;

View file

@ -612,6 +612,9 @@ public:
virtual std::string GetDriverInfo() const = 0;
// Executes current command buffer, waits for its completion, and destroys all pending resources.
virtual void ExecuteAndWaitForGPUIdle() = 0;
virtual std::unique_ptr<GPUTexture> CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples,
GPUTexture::Type type, GPUTexture::Format format,
const void* data = nullptr, u32 data_stride = 0) = 0;

View file

@ -208,6 +208,8 @@ public:
std::string GetDriverInfo() const override;
void ExecuteAndWaitForGPUIdle() override;
std::unique_ptr<GPUTexture> CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples,
GPUTexture::Type type, GPUTexture::Format format,
const void* data = nullptr, u32 data_stride = 0) override;

View file

@ -2468,6 +2468,12 @@ void MetalDevice::WaitForPreviousCommandBuffers()
WaitForFenceCounter(m_current_fence_counter - 1);
}
void MetalDevice::ExecuteAndWaitForGPUIdle()
{
SubmitCommandBuffer(true);
CleanupObjects();
}
void MetalDevice::CleanupObjects()
{
const u64 counter = m_completed_fence_counter.load(std::memory_order_acquire);

View file

@ -582,6 +582,12 @@ std::string OpenGLDevice::GetDriverInfo() const
gl_shading_language_version);
}
void OpenGLDevice::ExecuteAndWaitForGPUIdle()
{
// Could be glFinish(), but I'm afraid for mobile drivers...
glFlush();
}
void OpenGLDevice::SetSwapInterval()
{
if (m_window_info.type == WindowInfo::Type::Surfaceless)

View file

@ -48,6 +48,8 @@ public:
std::string GetDriverInfo() const override;
void ExecuteAndWaitForGPUIdle() override;
std::unique_ptr<GPUTexture> CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples,
GPUTexture::Type type, GPUTexture::Format format,
const void* data = nullptr, u32 data_stride = 0) override;

View file

@ -2370,6 +2370,14 @@ std::string VulkanDevice::GetDriverInfo() const
return ret;
}
void VulkanDevice::ExecuteAndWaitForGPUIdle()
{
if (InRenderPass())
EndRenderPass();
SubmitCommandBuffer(true);
}
void VulkanDevice::SetVSyncMode(GPUVSyncMode mode, bool allow_present_throttle)
{
m_allow_present_throttle = allow_present_throttle;

View file

@ -82,6 +82,8 @@ public:
std::string GetDriverInfo() const override;
void ExecuteAndWaitForGPUIdle() override;
std::unique_ptr<GPUTexture> CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples,
GPUTexture::Type type, GPUTexture::Format format,
const void* data = nullptr, u32 data_stride = 0) override;