2025-04-16 13:38:32 -07:00
|
|
|
/* Copyright (C) 2025 Wildfire Games.
|
2023-12-02 16:30:12 -08:00
|
|
|
* This file is part of 0 A.D.
|
2022-05-08 15:02:46 -07:00
|
|
|
*
|
2023-12-02 16:30:12 -08:00
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
2022-05-08 15:02:46 -07:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
2023-12-02 16:30:12 -08:00
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
2022-05-08 15:02:46 -07:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2023-12-02 16:30:12 -08:00
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
2022-05-08 15:02:46 -07:00
|
|
|
*/
|
|
|
|
|
|
2022-10-07 16:02:15 -07:00
|
|
|
#ifndef INCLUDED_RENDERER_BACKEND_DUMMY_DEVICECOMMANDCONTEXT
|
|
|
|
|
#define INCLUDED_RENDERER_BACKEND_DUMMY_DEVICECOMMANDCONTEXT
|
2022-05-08 15:02:46 -07:00
|
|
|
|
2025-07-06 11:15:27 -07:00
|
|
|
#include "lib/types.h"
|
2022-05-08 15:02:46 -07:00
|
|
|
#include "renderer/backend/IDeviceCommandContext.h"
|
|
|
|
|
|
2025-07-06 11:15:27 -07:00
|
|
|
#include <cstddef>
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <functional>
|
2022-05-08 15:02:46 -07:00
|
|
|
#include <memory>
|
2025-08-13 08:20:49 -07:00
|
|
|
#include <span>
|
2022-05-08 15:02:46 -07:00
|
|
|
|
2025-07-06 11:15:27 -07:00
|
|
|
namespace Renderer::Backend::Dummy { class CDevice; }
|
|
|
|
|
|
2022-05-08 15:02:46 -07:00
|
|
|
namespace Renderer
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
namespace Backend
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
namespace Dummy
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
class CDeviceCommandContext : public IDeviceCommandContext
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
~CDeviceCommandContext();
|
|
|
|
|
|
|
|
|
|
IDevice* GetDevice() override;
|
|
|
|
|
|
2022-12-31 10:29:44 -08:00
|
|
|
void SetGraphicsPipelineState(IGraphicsPipelineState* pipelineState) override;
|
2024-01-17 11:40:27 -08:00
|
|
|
void SetComputePipelineState(IComputePipelineState* pipelineState) override;
|
2022-05-08 15:02:46 -07:00
|
|
|
|
2023-02-17 09:36:10 -08:00
|
|
|
void BlitFramebuffer(
|
|
|
|
|
IFramebuffer* sourceFramebuffer, IFramebuffer* destinationFramebuffer,
|
|
|
|
|
const Rect& sourceRegion, const Rect& destinationRegion,
|
|
|
|
|
const Sampler::Filter filter) override;
|
|
|
|
|
void ResolveFramebuffer(
|
|
|
|
|
IFramebuffer* sourceFramebuffer, IFramebuffer* destinationFramebuffer) override;
|
2022-05-08 15:02:46 -07:00
|
|
|
|
|
|
|
|
void ClearFramebuffer(const bool color, const bool depth, const bool stencil) override;
|
2022-10-12 14:51:27 -07:00
|
|
|
void BeginFramebufferPass(IFramebuffer* framebuffer) override;
|
|
|
|
|
void EndFramebufferPass() override;
|
2022-05-08 15:02:46 -07:00
|
|
|
void ReadbackFramebufferSync(
|
|
|
|
|
const uint32_t x, const uint32_t y, const uint32_t width, const uint32_t height,
|
|
|
|
|
void* data) override;
|
|
|
|
|
|
|
|
|
|
void UploadTexture(ITexture* texture, const Format dataFormat,
|
|
|
|
|
const void* data, const size_t dataSize,
|
|
|
|
|
const uint32_t level = 0, const uint32_t layer = 0) override;
|
|
|
|
|
void UploadTextureRegion(ITexture* texture, const Format dataFormat,
|
|
|
|
|
const void* data, const size_t dataSize,
|
|
|
|
|
const uint32_t xOffset, const uint32_t yOffset,
|
|
|
|
|
const uint32_t width, const uint32_t height,
|
|
|
|
|
const uint32_t level = 0, const uint32_t layer = 0) override;
|
|
|
|
|
|
|
|
|
|
using UploadBufferFunction = std::function<void(u8*)>;
|
|
|
|
|
void UploadBuffer(IBuffer* buffer, const void* data, const uint32_t dataSize) override;
|
|
|
|
|
void UploadBuffer(IBuffer* buffer, const UploadBufferFunction& uploadFunction) override;
|
|
|
|
|
void UploadBufferRegion(
|
|
|
|
|
IBuffer* buffer, const void* data, const uint32_t dataOffset, const uint32_t dataSize) override;
|
|
|
|
|
void UploadBufferRegion(
|
|
|
|
|
IBuffer* buffer, const uint32_t dataOffset, const uint32_t dataSize,
|
|
|
|
|
const UploadBufferFunction& uploadFunction) override;
|
|
|
|
|
|
|
|
|
|
void SetScissors(const uint32_t scissorCount, const Rect* scissors) override;
|
|
|
|
|
void SetViewports(const uint32_t viewportCount, const Rect* viewports) override;
|
|
|
|
|
|
2023-01-05 16:39:25 -08:00
|
|
|
void SetVertexInputLayout(
|
|
|
|
|
IVertexInputLayout* vertexInputLayout) override;
|
|
|
|
|
|
2022-10-09 04:47:34 -07:00
|
|
|
void SetVertexBuffer(
|
|
|
|
|
const uint32_t bindingSlot, IBuffer* buffer, const uint32_t offset) override;
|
2022-05-24 00:11:23 -07:00
|
|
|
void SetVertexBufferData(
|
|
|
|
|
const uint32_t bindingSlot, const void* data, const uint32_t dataSize) override;
|
2022-05-08 15:02:46 -07:00
|
|
|
|
|
|
|
|
void SetIndexBuffer(IBuffer* buffer) override;
|
2022-05-24 00:11:23 -07:00
|
|
|
void SetIndexBufferData(const void* data, const uint32_t dataSize) override;
|
2022-05-08 15:02:46 -07:00
|
|
|
|
|
|
|
|
void BeginPass() override;
|
|
|
|
|
void EndPass() override;
|
|
|
|
|
|
|
|
|
|
void Draw(const uint32_t firstVertex, const uint32_t vertexCount) override;
|
|
|
|
|
void DrawIndexed(
|
|
|
|
|
const uint32_t firstIndex, const uint32_t indexCount, const int32_t vertexOffset) override;
|
2022-05-24 00:11:23 -07:00
|
|
|
void DrawInstanced(
|
|
|
|
|
const uint32_t firstVertex, const uint32_t vertexCount,
|
|
|
|
|
const uint32_t firstInstance, const uint32_t instanceCount) override;
|
|
|
|
|
void DrawIndexedInstanced(
|
|
|
|
|
const uint32_t firstIndex, const uint32_t indexCount,
|
|
|
|
|
const uint32_t firstInstance, const uint32_t instanceCount,
|
|
|
|
|
const int32_t vertexOffset) override;
|
2022-05-08 15:02:46 -07:00
|
|
|
void DrawIndexedInRange(
|
|
|
|
|
const uint32_t firstIndex, const uint32_t indexCount,
|
|
|
|
|
const uint32_t start, const uint32_t end) override;
|
|
|
|
|
|
2024-01-17 11:40:27 -08:00
|
|
|
void BeginComputePass() override;
|
|
|
|
|
void EndComputePass() override;
|
|
|
|
|
|
|
|
|
|
void Dispatch(
|
|
|
|
|
const uint32_t groupCountX,
|
|
|
|
|
const uint32_t groupCountY,
|
|
|
|
|
const uint32_t groupCountZ) override;
|
|
|
|
|
|
2024-12-09 13:47:15 -08:00
|
|
|
void InsertMemoryBarrier(
|
|
|
|
|
const uint32_t srcStageMask, const uint32_t dstStageMask,
|
|
|
|
|
const uint32_t srcAccessMask, const uint32_t dstAccessMask) override;
|
|
|
|
|
|
2022-05-08 15:02:46 -07:00
|
|
|
void SetTexture(const int32_t bindingSlot, ITexture* texture) override;
|
|
|
|
|
|
2024-01-17 11:40:27 -08:00
|
|
|
void SetStorageTexture(const int32_t bindingSlot, ITexture* texture) override;
|
2024-12-09 13:47:15 -08:00
|
|
|
void SetStorageBuffer(const int32_t bindingSlot, IBuffer* buffer) override;
|
2024-01-17 11:40:27 -08:00
|
|
|
|
2022-05-08 15:02:46 -07:00
|
|
|
void SetUniform(
|
|
|
|
|
const int32_t bindingSlot,
|
|
|
|
|
const float value) override;
|
|
|
|
|
void SetUniform(
|
|
|
|
|
const int32_t bindingSlot,
|
|
|
|
|
const float valueX, const float valueY) override;
|
|
|
|
|
void SetUniform(
|
|
|
|
|
const int32_t bindingSlot,
|
|
|
|
|
const float valueX, const float valueY,
|
|
|
|
|
const float valueZ) override;
|
|
|
|
|
void SetUniform(
|
|
|
|
|
const int32_t bindingSlot,
|
|
|
|
|
const float valueX, const float valueY,
|
|
|
|
|
const float valueZ, const float valueW) override;
|
|
|
|
|
void SetUniform(
|
2025-08-13 08:20:49 -07:00
|
|
|
const int32_t bindingSlot, std::span<const float> values) override;
|
2022-05-08 15:02:46 -07:00
|
|
|
|
2025-04-16 13:38:32 -07:00
|
|
|
void InsertTimestampQuery(const uint32_t handle, const bool isScopeBegin) override;
|
|
|
|
|
|
2022-05-08 15:02:46 -07:00
|
|
|
void BeginScopedLabel(const char* name) override;
|
|
|
|
|
void EndScopedLabel() override;
|
|
|
|
|
|
|
|
|
|
void Flush() override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
friend class CDevice;
|
|
|
|
|
|
|
|
|
|
static std::unique_ptr<CDeviceCommandContext> Create(CDevice* device);
|
|
|
|
|
|
|
|
|
|
CDeviceCommandContext();
|
|
|
|
|
|
|
|
|
|
CDevice* m_Device = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Dummy
|
|
|
|
|
|
|
|
|
|
} // namespace Backend
|
|
|
|
|
|
|
|
|
|
} // namespace Renderer
|
|
|
|
|
|
2022-10-07 16:02:15 -07:00
|
|
|
#endif // INCLUDED_RENDERER_BACKEND_DUMMY_DEVICECOMMANDCONTEXT
|