Add renderer API validation tests
This commit is contained in:
60
src/renderer_api/renderer_api.h
Normal file
60
src/renderer_api/renderer_api.h
Normal file
@@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
#include "foundation/result.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace pp::renderer {
|
||||
|
||||
constexpr std::uint32_t max_texture_dimension = 32768;
|
||||
constexpr std::uint64_t max_texture_bytes = 1024ULL * 1024ULL * 1024ULL;
|
||||
|
||||
enum class TextureFormat : std::uint8_t {
|
||||
rgba8,
|
||||
r8,
|
||||
depth24_stencil8,
|
||||
};
|
||||
|
||||
struct Extent2D {
|
||||
std::uint32_t width = 0;
|
||||
std::uint32_t height = 0;
|
||||
};
|
||||
|
||||
struct TextureDesc {
|
||||
Extent2D extent;
|
||||
TextureFormat format = TextureFormat::rgba8;
|
||||
bool render_target = false;
|
||||
};
|
||||
|
||||
struct ReadbackRegion {
|
||||
std::uint32_t x = 0;
|
||||
std::uint32_t y = 0;
|
||||
std::uint32_t width = 0;
|
||||
std::uint32_t height = 0;
|
||||
};
|
||||
|
||||
class ITexture2D {
|
||||
public:
|
||||
virtual ~ITexture2D() = default;
|
||||
[[nodiscard]] virtual TextureDesc desc() const noexcept = 0;
|
||||
};
|
||||
|
||||
class IReadbackBuffer {
|
||||
public:
|
||||
virtual ~IReadbackBuffer() = default;
|
||||
[[nodiscard]] virtual std::uint64_t size_bytes() const noexcept = 0;
|
||||
};
|
||||
|
||||
class IRenderTrace {
|
||||
public:
|
||||
virtual ~IRenderTrace() = default;
|
||||
virtual void marker(const char* component, const char* name) noexcept = 0;
|
||||
};
|
||||
|
||||
[[nodiscard]] std::uint32_t bytes_per_pixel(TextureFormat format) noexcept;
|
||||
[[nodiscard]] pp::foundation::Status validate_extent(Extent2D extent) noexcept;
|
||||
[[nodiscard]] pp::foundation::Result<std::uint64_t> texture_byte_size(TextureDesc desc) noexcept;
|
||||
[[nodiscard]] pp::foundation::Status validate_readback_region(TextureDesc desc, ReadbackRegion region) noexcept;
|
||||
[[nodiscard]] const char* texture_format_name(TextureFormat format) noexcept;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user