2014-08-17 10:16:57 +00:00
|
|
|
// Very thin API wrapper, suitable for porting UI code (like the native/ui framework) and similar but not real rendering.
|
|
|
|
// Does not involve context creation etc, that should be handled separately - only does drawing.
|
|
|
|
|
|
|
|
// The goals may change in the future though.
|
2018-05-29 21:30:41 +00:00
|
|
|
// MIT licensed, by Henrik Rydgård 2014.
|
2014-08-17 10:16:57 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-10-08 01:22:23 +00:00
|
|
|
#include <atomic>
|
2018-02-25 09:27:59 +00:00
|
|
|
#include <cstdint>
|
2014-08-23 09:11:45 +00:00
|
|
|
#include <cstddef>
|
2020-05-11 16:47:26 +00:00
|
|
|
#include <functional>
|
2014-09-06 11:49:01 +00:00
|
|
|
#include <string>
|
2020-05-11 16:47:26 +00:00
|
|
|
#include <vector>
|
2014-08-17 10:16:57 +00:00
|
|
|
|
2020-11-04 08:40:11 +00:00
|
|
|
#include "Common/GPU/DataFormat.h"
|
|
|
|
#include "Common/GPU/Shader.h"
|
2022-08-05 08:00:27 +00:00
|
|
|
#include "Common/Data/Collections/Slice.h"
|
2016-04-09 16:21:31 +00:00
|
|
|
|
2019-10-22 20:58:10 +00:00
|
|
|
namespace Lin {
|
2014-08-17 10:16:57 +00:00
|
|
|
class Matrix4x4;
|
2019-10-22 20:58:10 +00:00
|
|
|
}
|
2014-08-17 10:16:57 +00:00
|
|
|
|
2016-12-25 17:18:19 +00:00
|
|
|
namespace Draw {
|
|
|
|
|
2016-12-25 17:52:05 +00:00
|
|
|
// Useful in UBOs
|
|
|
|
typedef int bool32;
|
|
|
|
|
2022-07-20 09:09:32 +00:00
|
|
|
enum class Comparison : uint8_t {
|
2014-08-17 10:16:57 +00:00
|
|
|
NEVER,
|
|
|
|
LESS,
|
|
|
|
EQUAL,
|
|
|
|
LESS_EQUAL,
|
|
|
|
GREATER,
|
|
|
|
NOT_EQUAL,
|
|
|
|
GREATER_EQUAL,
|
|
|
|
ALWAYS,
|
|
|
|
};
|
|
|
|
|
2015-01-04 16:57:52 +00:00
|
|
|
// Had to prefix with LOGIC, too many clashes
|
2022-07-20 09:09:32 +00:00
|
|
|
enum class LogicOp : uint8_t {
|
2015-01-04 16:57:52 +00:00
|
|
|
LOGIC_CLEAR,
|
|
|
|
LOGIC_SET,
|
|
|
|
LOGIC_COPY,
|
|
|
|
LOGIC_COPY_INVERTED,
|
|
|
|
LOGIC_NOOP,
|
|
|
|
LOGIC_INVERT,
|
|
|
|
LOGIC_AND,
|
|
|
|
LOGIC_NAND,
|
|
|
|
LOGIC_OR,
|
|
|
|
LOGIC_NOR,
|
|
|
|
LOGIC_XOR,
|
|
|
|
LOGIC_EQUIV,
|
|
|
|
LOGIC_AND_REVERSE,
|
|
|
|
LOGIC_AND_INVERTED,
|
|
|
|
LOGIC_OR_REVERSE,
|
|
|
|
LOGIC_OR_INVERTED,
|
|
|
|
};
|
|
|
|
|
2022-07-20 09:09:32 +00:00
|
|
|
enum class BlendOp : uint8_t {
|
2016-12-26 22:51:17 +00:00
|
|
|
ADD,
|
|
|
|
SUBTRACT,
|
|
|
|
REV_SUBTRACT,
|
|
|
|
MIN,
|
|
|
|
MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class BlendFactor : uint8_t {
|
2014-08-17 10:16:57 +00:00
|
|
|
ZERO,
|
|
|
|
ONE,
|
|
|
|
SRC_COLOR,
|
|
|
|
ONE_MINUS_SRC_COLOR,
|
|
|
|
DST_COLOR,
|
|
|
|
ONE_MINUS_DST_COLOR,
|
2016-12-26 22:51:17 +00:00
|
|
|
SRC_ALPHA,
|
|
|
|
ONE_MINUS_SRC_ALPHA,
|
|
|
|
DST_ALPHA,
|
2014-08-17 10:16:57 +00:00
|
|
|
ONE_MINUS_DST_ALPHA,
|
2016-12-26 22:51:17 +00:00
|
|
|
CONSTANT_COLOR,
|
|
|
|
ONE_MINUS_CONSTANT_COLOR,
|
|
|
|
CONSTANT_ALPHA,
|
|
|
|
ONE_MINUS_CONSTANT_ALPHA,
|
|
|
|
SRC1_COLOR,
|
|
|
|
ONE_MINUS_SRC1_COLOR,
|
|
|
|
SRC1_ALPHA,
|
|
|
|
ONE_MINUS_SRC1_ALPHA,
|
2014-08-17 10:16:57 +00:00
|
|
|
};
|
|
|
|
|
2016-12-26 22:11:31 +00:00
|
|
|
enum class StencilOp {
|
|
|
|
KEEP = 0,
|
|
|
|
ZERO = 1,
|
|
|
|
REPLACE = 2,
|
|
|
|
INCREMENT_AND_CLAMP = 3,
|
|
|
|
DECREMENT_AND_CLAMP = 4,
|
|
|
|
INVERT = 5,
|
|
|
|
INCREMENT_AND_WRAP = 6,
|
|
|
|
DECREMENT_AND_WRAP = 7,
|
|
|
|
};
|
|
|
|
|
2022-07-20 09:09:32 +00:00
|
|
|
enum class TextureFilter : uint8_t {
|
2017-02-19 10:22:23 +00:00
|
|
|
NEAREST = 0,
|
|
|
|
LINEAR = 1,
|
2016-02-13 21:37:00 +00:00
|
|
|
};
|
|
|
|
|
2016-12-25 17:52:05 +00:00
|
|
|
enum BufferUsageFlag : int {
|
2014-08-17 10:16:57 +00:00
|
|
|
VERTEXDATA = 1,
|
|
|
|
INDEXDATA = 2,
|
|
|
|
GENERIC = 4,
|
2017-02-07 17:04:31 +00:00
|
|
|
UNIFORM = 8,
|
2014-08-17 10:16:57 +00:00
|
|
|
|
|
|
|
DYNAMIC = 16,
|
|
|
|
};
|
|
|
|
|
2016-12-25 17:52:05 +00:00
|
|
|
enum Semantic : int {
|
2014-08-17 10:16:57 +00:00
|
|
|
SEM_POSITION,
|
|
|
|
SEM_COLOR0,
|
|
|
|
SEM_TEXCOORD0,
|
2014-08-17 12:08:55 +00:00
|
|
|
SEM_TEXCOORD1,
|
2014-08-17 10:16:57 +00:00
|
|
|
SEM_NORMAL,
|
|
|
|
SEM_TANGENT,
|
|
|
|
SEM_BINORMAL, // really BITANGENT
|
|
|
|
SEM_MAX,
|
|
|
|
};
|
|
|
|
|
2016-12-25 17:52:05 +00:00
|
|
|
enum class Primitive {
|
|
|
|
POINT_LIST,
|
|
|
|
LINE_LIST,
|
|
|
|
LINE_STRIP,
|
|
|
|
TRIANGLE_LIST,
|
|
|
|
TRIANGLE_STRIP,
|
|
|
|
TRIANGLE_FAN,
|
2016-12-25 20:01:57 +00:00
|
|
|
// Tesselation shader only
|
2016-12-25 17:52:05 +00:00
|
|
|
PATCH_LIST,
|
|
|
|
// These are for geometry shaders only.
|
|
|
|
LINE_LIST_ADJ,
|
|
|
|
LINE_STRIP_ADJ,
|
|
|
|
TRIANGLE_LIST_ADJ,
|
|
|
|
TRIANGLE_STRIP_ADJ,
|
2017-02-07 10:44:44 +00:00
|
|
|
|
|
|
|
UNDEFINED,
|
2020-07-28 11:24:02 +00:00
|
|
|
PRIMITIVE_TYPE_COUNT,
|
2014-08-17 10:16:57 +00:00
|
|
|
};
|
|
|
|
|
2016-12-25 19:54:37 +00:00
|
|
|
enum VertexShaderPreset : int {
|
2014-08-17 10:16:57 +00:00
|
|
|
VS_COLOR_2D,
|
|
|
|
VS_TEXTURE_COLOR_2D,
|
|
|
|
VS_MAX_PRESET,
|
|
|
|
};
|
|
|
|
|
2016-12-25 19:54:37 +00:00
|
|
|
enum FragmentShaderPreset : int {
|
2014-08-17 10:16:57 +00:00
|
|
|
FS_COLOR_2D,
|
|
|
|
FS_TEXTURE_COLOR_2D,
|
2019-10-23 22:51:55 +00:00
|
|
|
FS_TEXTURE_COLOR_2D_RB_SWIZZLE,
|
2014-08-17 10:16:57 +00:00
|
|
|
FS_MAX_PRESET,
|
|
|
|
};
|
|
|
|
|
2017-01-16 16:43:07 +00:00
|
|
|
enum class TextureType : uint8_t {
|
2014-09-06 11:49:01 +00:00
|
|
|
UNKNOWN,
|
|
|
|
LINEAR1D,
|
|
|
|
LINEAR2D,
|
|
|
|
LINEAR3D,
|
|
|
|
CUBE,
|
|
|
|
ARRAY1D,
|
|
|
|
ARRAY2D,
|
|
|
|
};
|
|
|
|
|
2016-12-26 22:11:31 +00:00
|
|
|
enum class CullMode : uint8_t {
|
|
|
|
NONE,
|
|
|
|
FRONT,
|
|
|
|
BACK,
|
|
|
|
FRONT_AND_BACK, // Not supported on D3D9
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class Facing {
|
|
|
|
CCW,
|
|
|
|
CW,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum BorderColor {
|
|
|
|
DONT_CARE,
|
|
|
|
TRANSPARENT_BLACK,
|
|
|
|
OPAQUE_BLACK,
|
|
|
|
OPAQUE_WHITE,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
COLOR_MASK_R = 1,
|
|
|
|
COLOR_MASK_G = 2,
|
|
|
|
COLOR_MASK_B = 4,
|
|
|
|
COLOR_MASK_A = 8,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class TextureAddressMode {
|
2017-02-19 10:22:23 +00:00
|
|
|
REPEAT = 0,
|
2016-12-26 22:11:31 +00:00
|
|
|
REPEAT_MIRROR,
|
|
|
|
CLAMP_TO_EDGE,
|
|
|
|
CLAMP_TO_BORDER,
|
|
|
|
};
|
|
|
|
|
2017-01-19 05:16:36 +00:00
|
|
|
enum FormatSupport {
|
|
|
|
FMT_RENDERTARGET = 1,
|
|
|
|
FMT_TEXTURE = 2,
|
|
|
|
FMT_INPUTLAYOUT = 4,
|
2017-02-22 15:23:04 +00:00
|
|
|
FMT_DEPTHSTENCIL = 8,
|
2017-03-11 13:43:42 +00:00
|
|
|
FMT_AUTOGEN_MIPS = 16,
|
2022-08-01 21:21:14 +00:00
|
|
|
FMT_BLIT = 32,
|
|
|
|
FMT_STORAGE_IMAGE = 64,
|
2017-01-19 05:16:36 +00:00
|
|
|
};
|
|
|
|
|
2016-12-25 17:52:05 +00:00
|
|
|
enum InfoField {
|
2014-09-06 11:49:01 +00:00
|
|
|
APINAME,
|
|
|
|
APIVERSION,
|
2015-07-21 18:46:31 +00:00
|
|
|
VENDORSTRING,
|
2014-09-06 11:49:01 +00:00
|
|
|
VENDOR,
|
|
|
|
SHADELANGVERSION,
|
2017-03-16 08:48:10 +00:00
|
|
|
DRIVER,
|
2014-09-06 11:49:01 +00:00
|
|
|
};
|
|
|
|
|
2017-11-21 14:42:01 +00:00
|
|
|
enum class GPUVendor {
|
2017-11-22 10:01:42 +00:00
|
|
|
VENDOR_UNKNOWN,
|
|
|
|
VENDOR_NVIDIA,
|
|
|
|
VENDOR_INTEL,
|
|
|
|
VENDOR_AMD,
|
|
|
|
VENDOR_ARM, // Mali
|
|
|
|
VENDOR_QUALCOMM,
|
|
|
|
VENDOR_IMGTEC, // PowerVR
|
|
|
|
VENDOR_BROADCOM, // Raspberry
|
2019-01-03 11:43:00 +00:00
|
|
|
VENDOR_VIVANTE,
|
2020-12-14 21:10:18 +00:00
|
|
|
VENDOR_APPLE,
|
2017-11-21 14:42:01 +00:00
|
|
|
};
|
|
|
|
|
2017-02-05 19:05:03 +00:00
|
|
|
enum class NativeObject {
|
|
|
|
CONTEXT,
|
2017-02-18 00:54:28 +00:00
|
|
|
CONTEXT_EX,
|
2017-02-05 19:05:03 +00:00
|
|
|
DEVICE,
|
|
|
|
DEVICE_EX,
|
2017-02-08 17:07:34 +00:00
|
|
|
BACKBUFFER_COLOR_VIEW,
|
|
|
|
BACKBUFFER_DEPTH_VIEW,
|
2017-02-17 23:43:02 +00:00
|
|
|
BACKBUFFER_COLOR_TEX,
|
|
|
|
BACKBUFFER_DEPTH_TEX,
|
2017-03-05 11:26:46 +00:00
|
|
|
FEATURE_LEVEL,
|
2017-08-19 15:32:10 +00:00
|
|
|
INIT_COMMANDBUFFER,
|
2017-10-31 11:02:10 +00:00
|
|
|
BOUND_TEXTURE0_IMAGEVIEW,
|
|
|
|
BOUND_TEXTURE1_IMAGEVIEW,
|
2017-08-16 21:03:30 +00:00
|
|
|
RENDER_MANAGER,
|
2022-08-05 09:44:09 +00:00
|
|
|
TEXTURE_VIEW,
|
2018-06-01 16:51:37 +00:00
|
|
|
NULL_IMAGEVIEW,
|
2017-02-05 19:05:03 +00:00
|
|
|
};
|
|
|
|
|
2017-02-04 17:46:12 +00:00
|
|
|
enum FBChannel {
|
|
|
|
FB_COLOR_BIT = 1,
|
|
|
|
FB_DEPTH_BIT = 2,
|
|
|
|
FB_STENCIL_BIT = 4,
|
2017-02-15 10:06:59 +00:00
|
|
|
|
|
|
|
// Implementation specific
|
2017-02-04 17:46:12 +00:00
|
|
|
FB_SURFACE_BIT = 32, // Used in conjunction with the others in D3D9 to get surfaces through get_api_texture
|
2017-02-23 15:27:26 +00:00
|
|
|
FB_VIEW_BIT = 64, // Used in conjunction with the others in D3D11 to get shader resource views through get_api_texture
|
|
|
|
FB_FORMAT_BIT = 128, // Actually retrieves the native format instead. D3D11 only.
|
2017-02-04 17:46:12 +00:00
|
|
|
};
|
|
|
|
|
2022-08-28 21:16:48 +00:00
|
|
|
enum FBInvalidationStage {
|
|
|
|
FB_INVALIDATION_LOAD = 1,
|
|
|
|
FB_INVALIDATION_STORE = 2,
|
|
|
|
};
|
|
|
|
|
2017-02-04 17:46:12 +00:00
|
|
|
enum FBBlitFilter {
|
|
|
|
FB_BLIT_NEAREST = 0,
|
|
|
|
FB_BLIT_LINEAR = 1,
|
|
|
|
};
|
|
|
|
|
2017-02-07 18:41:58 +00:00
|
|
|
enum UpdateBufferFlags {
|
|
|
|
UPDATE_DISCARD = 1,
|
|
|
|
};
|
|
|
|
|
2017-02-06 10:20:27 +00:00
|
|
|
enum class Event {
|
2017-02-27 09:28:57 +00:00
|
|
|
// These happen on D3D resize. Only the backbuffer needs to be resized.
|
2017-02-06 10:20:27 +00:00
|
|
|
LOST_BACKBUFFER,
|
|
|
|
GOT_BACKBUFFER,
|
2017-02-27 09:28:57 +00:00
|
|
|
|
|
|
|
// These are a bit more serious...
|
|
|
|
LOST_DEVICE,
|
|
|
|
GOT_DEVICE,
|
|
|
|
|
2017-02-09 23:30:42 +00:00
|
|
|
RESIZED,
|
2017-03-16 13:44:22 +00:00
|
|
|
PRESENTED,
|
2017-02-06 10:20:27 +00:00
|
|
|
};
|
|
|
|
|
2021-06-12 17:54:36 +00:00
|
|
|
constexpr uint32_t MAX_TEXTURE_SLOTS = 3;
|
2020-07-27 16:22:23 +00:00
|
|
|
|
2017-02-04 17:46:12 +00:00
|
|
|
struct FramebufferDesc {
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int depth;
|
|
|
|
int numColorAttachments;
|
|
|
|
bool z_stencil;
|
2020-08-08 21:18:17 +00:00
|
|
|
const char *tag; // For graphics debuggers
|
2017-02-04 17:46:12 +00:00
|
|
|
};
|
|
|
|
|
2014-08-17 10:16:57 +00:00
|
|
|
// Binary compatible with D3D11 viewport.
|
2016-12-25 17:52:05 +00:00
|
|
|
struct Viewport {
|
2014-08-17 10:16:57 +00:00
|
|
|
float TopLeftX;
|
|
|
|
float TopLeftY;
|
|
|
|
float Width;
|
|
|
|
float Height;
|
|
|
|
float MinDepth;
|
|
|
|
float MaxDepth;
|
|
|
|
};
|
|
|
|
|
2018-12-23 20:19:34 +00:00
|
|
|
class Bugs {
|
|
|
|
public:
|
|
|
|
bool Has(uint32_t bug) const {
|
|
|
|
return (flags_ & (1 << bug)) != 0;
|
|
|
|
}
|
|
|
|
void Infest(uint32_t bug) {
|
|
|
|
flags_ |= (1 << bug);
|
|
|
|
}
|
2022-05-08 23:15:40 +00:00
|
|
|
uint32_t MaxBugIndex() const {
|
|
|
|
return (uint32_t)MAX_BUG;
|
|
|
|
}
|
|
|
|
const char *GetBugName(uint32_t bug);
|
2018-12-23 20:19:34 +00:00
|
|
|
|
|
|
|
enum : uint32_t {
|
|
|
|
NO_DEPTH_CANNOT_DISCARD_STENCIL = 0,
|
2018-12-23 20:31:19 +00:00
|
|
|
DUAL_SOURCE_BLENDING_BROKEN = 1,
|
2018-12-23 20:46:48 +00:00
|
|
|
ANY_MAP_BUFFER_RANGE_SLOW = 2,
|
|
|
|
PVR_GENMIPMAP_HEIGHT_GREATER = 3,
|
2019-01-03 11:43:00 +00:00
|
|
|
BROKEN_NAN_IN_CONDITIONAL = 4,
|
2020-05-20 05:12:30 +00:00
|
|
|
COLORWRITEMASK_BROKEN_WITH_DEPTHTEST = 5,
|
2020-12-16 13:25:00 +00:00
|
|
|
BROKEN_FLAT_IN_SHADER = 6,
|
2021-09-20 06:16:21 +00:00
|
|
|
EQUAL_WZ_CORRUPTS_DEPTH = 7,
|
2022-05-08 23:15:40 +00:00
|
|
|
MALI_STENCIL_DISCARD_BUG = 8,
|
2022-06-19 09:53:16 +00:00
|
|
|
RASPBERRY_SHADER_COMP_HANG = 9,
|
2022-07-17 20:50:37 +00:00
|
|
|
MALI_CONSTANT_LOAD_BUG = 10,
|
2022-05-08 23:15:40 +00:00
|
|
|
MAX_BUG,
|
2018-12-23 20:19:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
protected:
|
|
|
|
uint32_t flags_ = 0;
|
|
|
|
};
|
|
|
|
|
2016-12-25 20:01:57 +00:00
|
|
|
class RefCountedObject {
|
2014-08-17 10:16:57 +00:00
|
|
|
public:
|
2021-10-08 01:22:23 +00:00
|
|
|
RefCountedObject() {
|
|
|
|
refcount_ = 1;
|
|
|
|
}
|
2022-08-16 10:46:13 +00:00
|
|
|
RefCountedObject(const RefCountedObject &other) = delete;
|
|
|
|
RefCountedObject& operator=(RefCountedObject const&) = delete;
|
|
|
|
virtual ~RefCountedObject();
|
2014-08-17 10:16:57 +00:00
|
|
|
|
2016-12-26 17:32:52 +00:00
|
|
|
void AddRef() { refcount_++; }
|
|
|
|
bool Release();
|
2017-11-29 18:07:07 +00:00
|
|
|
bool ReleaseAssertLast();
|
2014-08-17 10:16:57 +00:00
|
|
|
|
|
|
|
private:
|
2021-10-08 01:22:23 +00:00
|
|
|
std::atomic<int> refcount_;
|
2014-08-17 10:16:57 +00:00
|
|
|
};
|
|
|
|
|
2021-02-16 08:47:26 +00:00
|
|
|
template <typename T>
|
|
|
|
struct AutoRef {
|
2022-06-19 09:53:16 +00:00
|
|
|
AutoRef() {}
|
2021-02-16 08:47:26 +00:00
|
|
|
explicit AutoRef(T *p) {
|
|
|
|
ptr = p;
|
|
|
|
if (ptr)
|
|
|
|
ptr->AddRef();
|
|
|
|
}
|
|
|
|
AutoRef(const AutoRef<T> &p) {
|
|
|
|
*this = p.ptr;
|
|
|
|
}
|
|
|
|
~AutoRef() {
|
|
|
|
if (ptr)
|
|
|
|
ptr->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
T *operator =(T *p) {
|
|
|
|
if (ptr)
|
|
|
|
ptr->Release();
|
|
|
|
ptr = p;
|
|
|
|
if (ptr)
|
|
|
|
ptr->AddRef();
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
AutoRef<T> &operator =(const AutoRef<T> &p) {
|
|
|
|
*this = p.ptr;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
T *operator->() const {
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
operator T *() {
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
T *ptr = nullptr;
|
|
|
|
};
|
|
|
|
|
2016-12-25 20:01:57 +00:00
|
|
|
class BlendState : public RefCountedObject {
|
2014-08-17 10:16:57 +00:00
|
|
|
public:
|
|
|
|
};
|
|
|
|
|
2016-12-25 20:01:57 +00:00
|
|
|
class SamplerState : public RefCountedObject {
|
2016-02-13 21:37:00 +00:00
|
|
|
public:
|
|
|
|
};
|
|
|
|
|
2016-12-25 20:01:57 +00:00
|
|
|
class DepthStencilState : public RefCountedObject {
|
2014-08-17 10:16:57 +00:00
|
|
|
public:
|
|
|
|
};
|
|
|
|
|
2017-02-04 17:46:12 +00:00
|
|
|
class Framebuffer : public RefCountedObject {
|
|
|
|
public:
|
2020-11-06 08:01:13 +00:00
|
|
|
int Width() { return width_; }
|
|
|
|
int Height() { return height_; }
|
|
|
|
protected:
|
|
|
|
int width_ = -1, height_ = -1;
|
2017-02-04 17:46:12 +00:00
|
|
|
};
|
|
|
|
|
2016-12-25 20:01:57 +00:00
|
|
|
class Buffer : public RefCountedObject {
|
2014-08-17 10:16:57 +00:00
|
|
|
public:
|
|
|
|
};
|
|
|
|
|
2016-12-25 20:01:57 +00:00
|
|
|
class Texture : public RefCountedObject {
|
2014-08-17 10:16:57 +00:00
|
|
|
public:
|
2014-08-17 19:28:34 +00:00
|
|
|
int Width() { return width_; }
|
|
|
|
int Height() { return height_; }
|
|
|
|
int Depth() { return depth_; }
|
|
|
|
protected:
|
2020-11-06 08:01:13 +00:00
|
|
|
int width_ = -1, height_ = -1, depth_ = -1;
|
2014-08-17 10:16:57 +00:00
|
|
|
};
|
|
|
|
|
2016-12-26 12:22:48 +00:00
|
|
|
struct BindingDesc {
|
|
|
|
int stride;
|
|
|
|
bool instanceRate;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AttributeDesc {
|
|
|
|
int binding;
|
|
|
|
int location; // corresponds to semantic
|
|
|
|
DataFormat format;
|
|
|
|
int offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct InputLayoutDesc {
|
|
|
|
std::vector<BindingDesc> bindings;
|
|
|
|
std::vector<AttributeDesc> attributes;
|
2014-08-17 12:08:55 +00:00
|
|
|
};
|
|
|
|
|
2016-12-26 16:03:01 +00:00
|
|
|
class InputLayout : public RefCountedObject { };
|
2014-08-17 10:16:57 +00:00
|
|
|
|
2020-11-03 14:44:57 +00:00
|
|
|
// Uniform types have moved to Shader.h.
|
2016-12-25 22:03:20 +00:00
|
|
|
|
2016-12-25 21:24:14 +00:00
|
|
|
class ShaderModule : public RefCountedObject {
|
|
|
|
public:
|
|
|
|
virtual ShaderStage GetStage() const = 0;
|
|
|
|
};
|
|
|
|
|
2016-12-26 10:06:17 +00:00
|
|
|
class Pipeline : public RefCountedObject {
|
2016-12-25 21:24:14 +00:00
|
|
|
public:
|
2017-02-10 14:40:51 +00:00
|
|
|
virtual ~Pipeline() {}
|
2016-12-25 21:24:14 +00:00
|
|
|
};
|
|
|
|
|
2016-12-26 16:03:01 +00:00
|
|
|
class RasterState : public RefCountedObject {};
|
2016-12-25 21:24:14 +00:00
|
|
|
|
2022-07-24 13:56:06 +00:00
|
|
|
struct StencilSetup {
|
2016-12-26 22:11:31 +00:00
|
|
|
StencilOp failOp;
|
|
|
|
StencilOp passOp;
|
|
|
|
StencilOp depthFailOp;
|
|
|
|
Comparison compareOp;
|
|
|
|
};
|
|
|
|
|
2016-12-25 20:10:46 +00:00
|
|
|
struct DepthStencilStateDesc {
|
|
|
|
bool depthTestEnabled;
|
|
|
|
bool depthWriteEnabled;
|
|
|
|
Comparison depthCompare;
|
2016-12-26 22:11:31 +00:00
|
|
|
bool stencilEnabled;
|
2022-07-24 13:56:06 +00:00
|
|
|
StencilSetup stencil;
|
2016-12-25 20:10:46 +00:00
|
|
|
};
|
|
|
|
|
2016-12-25 17:52:05 +00:00
|
|
|
struct BlendStateDesc {
|
2014-08-17 10:16:57 +00:00
|
|
|
bool enabled;
|
2016-12-26 17:32:52 +00:00
|
|
|
int colorMask;
|
2016-12-25 17:52:05 +00:00
|
|
|
BlendFactor srcCol;
|
|
|
|
BlendFactor dstCol;
|
|
|
|
BlendOp eqCol;
|
|
|
|
BlendFactor srcAlpha;
|
|
|
|
BlendFactor dstAlpha;
|
|
|
|
BlendOp eqAlpha;
|
2015-01-04 16:57:52 +00:00
|
|
|
bool logicEnabled;
|
2016-12-25 17:52:05 +00:00
|
|
|
LogicOp logicOp;
|
2016-12-26 17:32:52 +00:00
|
|
|
};
|
|
|
|
|
2016-12-25 19:54:37 +00:00
|
|
|
struct SamplerStateDesc {
|
2016-12-25 20:21:56 +00:00
|
|
|
TextureFilter magFilter;
|
|
|
|
TextureFilter minFilter;
|
|
|
|
TextureFilter mipFilter;
|
|
|
|
float maxAniso;
|
|
|
|
TextureAddressMode wrapU;
|
|
|
|
TextureAddressMode wrapV;
|
|
|
|
TextureAddressMode wrapW;
|
|
|
|
bool shadowCompareEnabled;
|
|
|
|
Comparison shadowCompareFunc;
|
|
|
|
BorderColor borderColor;
|
2016-02-13 21:37:00 +00:00
|
|
|
};
|
|
|
|
|
2016-12-25 21:24:14 +00:00
|
|
|
struct RasterStateDesc {
|
2016-12-25 17:52:05 +00:00
|
|
|
CullMode cull;
|
2016-12-27 14:52:03 +00:00
|
|
|
Facing frontFace;
|
2016-12-23 22:46:11 +00:00
|
|
|
};
|
|
|
|
|
2016-12-26 10:06:17 +00:00
|
|
|
struct PipelineDesc {
|
2016-12-26 16:03:01 +00:00
|
|
|
Primitive prim;
|
2016-12-25 22:03:20 +00:00
|
|
|
std::vector<ShaderModule *> shaders;
|
2016-12-26 16:03:01 +00:00
|
|
|
InputLayout *inputLayout;
|
|
|
|
DepthStencilState *depthStencil;
|
|
|
|
BlendState *blend;
|
|
|
|
RasterState *raster;
|
2017-02-08 11:55:58 +00:00
|
|
|
const UniformBufferDesc *uniformDesc;
|
2022-08-05 08:00:27 +00:00
|
|
|
const Slice<SamplerDef> samplers;
|
2016-12-25 22:03:20 +00:00
|
|
|
};
|
|
|
|
|
2016-12-26 16:31:20 +00:00
|
|
|
struct DeviceCaps {
|
2017-11-21 14:42:01 +00:00
|
|
|
GPUVendor vendor;
|
2019-02-06 21:43:31 +00:00
|
|
|
uint32_t deviceID; // use caution!
|
|
|
|
|
2016-12-26 16:31:20 +00:00
|
|
|
DataFormat preferredDepthBufferFormat;
|
|
|
|
DataFormat preferredShadowMapFormatLow;
|
|
|
|
DataFormat preferredShadowMapFormatHigh;
|
|
|
|
bool anisoSupported;
|
|
|
|
bool depthRangeMinusOneToOne; // OpenGL style depth
|
|
|
|
bool geometryShaderSupported;
|
|
|
|
bool tesselationShaderSupported;
|
|
|
|
bool multiViewport;
|
|
|
|
bool dualSourceBlend;
|
2017-02-18 00:10:46 +00:00
|
|
|
bool logicOpSupported;
|
2018-09-19 04:49:17 +00:00
|
|
|
bool depthClampSupported;
|
2021-09-19 14:14:54 +00:00
|
|
|
bool clipDistanceSupported;
|
|
|
|
bool cullDistanceSupported;
|
2017-02-12 17:29:58 +00:00
|
|
|
bool framebufferCopySupported;
|
|
|
|
bool framebufferBlitSupported;
|
2017-10-25 19:56:39 +00:00
|
|
|
bool framebufferDepthCopySupported;
|
2022-08-01 21:21:14 +00:00
|
|
|
bool framebufferSeparateDepthCopySupported;
|
2017-10-25 19:56:39 +00:00
|
|
|
bool framebufferDepthBlitSupported;
|
2022-08-03 11:40:21 +00:00
|
|
|
bool framebufferStencilBlitSupported;
|
2020-11-06 08:01:13 +00:00
|
|
|
bool framebufferFetchSupported;
|
2022-07-30 22:18:28 +00:00
|
|
|
bool texture3DSupported;
|
2022-08-05 12:18:22 +00:00
|
|
|
bool fragmentShaderInt32Supported;
|
2022-08-07 09:09:34 +00:00
|
|
|
bool textureNPOTFullySupported;
|
2022-08-08 10:07:50 +00:00
|
|
|
bool fragmentShaderDepthWriteSupported;
|
2022-08-24 09:26:07 +00:00
|
|
|
bool textureDepthSupported;
|
2022-07-30 22:18:28 +00:00
|
|
|
|
2018-04-15 07:56:37 +00:00
|
|
|
std::string deviceName; // The device name to use when creating the thin3d context, to get the same one.
|
2016-12-26 16:31:20 +00:00
|
|
|
};
|
|
|
|
|
2020-05-14 03:30:24 +00:00
|
|
|
// Use to write data directly to texture memory. initData is the pointer passed in TextureDesc.
|
2020-05-11 16:47:26 +00:00
|
|
|
// Important: only write to the provided pointer, don't read from it.
|
2020-05-14 03:30:24 +00:00
|
|
|
typedef std::function<bool(uint8_t *data, const uint8_t *initData, uint32_t w, uint32_t h, uint32_t d, uint32_t byteStride, uint32_t sliceByteStride)> TextureCallback;
|
2020-05-11 16:47:26 +00:00
|
|
|
|
2017-01-16 16:43:07 +00:00
|
|
|
struct TextureDesc {
|
|
|
|
TextureType type;
|
|
|
|
DataFormat format;
|
2022-09-12 13:34:32 +00:00
|
|
|
|
2017-01-16 16:43:07 +00:00
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int depth;
|
|
|
|
int mipLevels;
|
2017-03-11 13:43:42 +00:00
|
|
|
bool generateMips;
|
2020-08-08 21:18:17 +00:00
|
|
|
// Optional, for tracking memory usage and graphcis debuggers.
|
2020-08-09 07:35:56 +00:00
|
|
|
const char *tag;
|
2018-01-17 12:59:32 +00:00
|
|
|
// Does not take ownership over pointed-to data.
|
2020-05-11 16:47:26 +00:00
|
|
|
std::vector<const uint8_t *> initData;
|
|
|
|
TextureCallback initDataCallback;
|
2017-01-16 16:43:07 +00:00
|
|
|
};
|
|
|
|
|
2017-05-16 14:00:34 +00:00
|
|
|
enum class RPAction {
|
2022-08-28 21:16:48 +00:00
|
|
|
KEEP = 0,
|
|
|
|
CLEAR = 1,
|
|
|
|
DONT_CARE = 2,
|
2017-05-16 14:00:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct RenderPassInfo {
|
|
|
|
RPAction color;
|
|
|
|
RPAction depth;
|
2017-12-30 21:52:22 +00:00
|
|
|
RPAction stencil;
|
2017-05-16 14:00:34 +00:00
|
|
|
uint32_t clearColor;
|
|
|
|
float clearDepth;
|
|
|
|
uint8_t clearStencil;
|
2020-05-21 09:24:05 +00:00
|
|
|
const char *tag;
|
2017-05-16 14:00:34 +00:00
|
|
|
};
|
|
|
|
|
2017-02-06 10:20:27 +00:00
|
|
|
class DrawContext {
|
2014-08-17 10:16:57 +00:00
|
|
|
public:
|
2016-12-25 20:01:57 +00:00
|
|
|
virtual ~DrawContext();
|
2017-10-20 09:53:07 +00:00
|
|
|
bool CreatePresets();
|
2018-02-04 12:38:44 +00:00
|
|
|
void DestroyPresets();
|
2014-08-17 13:02:43 +00:00
|
|
|
|
2018-12-23 20:19:34 +00:00
|
|
|
Bugs GetBugs() const { return bugs_; }
|
|
|
|
|
2016-12-26 16:31:20 +00:00
|
|
|
virtual const DeviceCaps &GetDeviceCaps() const = 0;
|
2017-01-19 05:16:36 +00:00
|
|
|
virtual uint32_t GetDataFormatSupport(DataFormat fmt) const = 0;
|
2016-12-26 16:31:20 +00:00
|
|
|
virtual std::vector<std::string> GetFeatureList() const { return std::vector<std::string>(); }
|
2017-08-28 11:45:04 +00:00
|
|
|
virtual std::vector<std::string> GetExtensionList() const { return std::vector<std::string>(); }
|
2018-04-15 07:56:37 +00:00
|
|
|
virtual std::vector<std::string> GetDeviceList() const { return std::vector<std::string>(); }
|
2016-01-03 13:00:05 +00:00
|
|
|
|
2020-11-06 08:01:13 +00:00
|
|
|
// Describes the primary shader language that this implementation prefers.
|
|
|
|
const ShaderLanguageDesc &GetShaderLanguageDesc() {
|
|
|
|
return shaderLanguageDesc_;
|
|
|
|
}
|
|
|
|
|
2016-12-27 15:33:54 +00:00
|
|
|
virtual uint32_t GetSupportedShaderLanguages() const = 0;
|
|
|
|
|
2020-11-04 23:48:35 +00:00
|
|
|
virtual void SetErrorCallback(ErrorCallbackFn callback, void *userdata) {}
|
|
|
|
|
2016-12-26 16:03:01 +00:00
|
|
|
// Partial pipeline state, used to create pipelines. (in practice, in d3d11 they'll use the native state objects directly).
|
2022-08-16 09:47:38 +00:00
|
|
|
// TODO: Possibly ditch these and just put the descs directly in PipelineDesc since only D3D11 benefits.
|
2016-12-25 20:10:46 +00:00
|
|
|
virtual DepthStencilState *CreateDepthStencilState(const DepthStencilStateDesc &desc) = 0;
|
2016-12-25 17:52:05 +00:00
|
|
|
virtual BlendState *CreateBlendState(const BlendStateDesc &desc) = 0;
|
2016-12-25 19:54:37 +00:00
|
|
|
virtual SamplerState *CreateSamplerState(const SamplerStateDesc &desc) = 0;
|
2016-12-25 21:24:14 +00:00
|
|
|
virtual RasterState *CreateRasterState(const RasterStateDesc &desc) = 0;
|
2016-12-26 16:03:01 +00:00
|
|
|
// virtual ComputePipeline CreateComputePipeline(const ComputePipelineDesc &desc) = 0
|
2016-12-26 12:22:48 +00:00
|
|
|
virtual InputLayout *CreateInputLayout(const InputLayoutDesc &desc) = 0;
|
2022-09-07 21:55:33 +00:00
|
|
|
virtual ShaderModule *CreateShaderModule(ShaderStage stage, ShaderLanguage language, const uint8_t *data, size_t dataSize, const char *tag = "thin3d") = 0;
|
|
|
|
virtual Pipeline *CreateGraphicsPipeline(const PipelineDesc &desc, const char *tag) = 0;
|
2014-09-06 11:49:01 +00:00
|
|
|
|
2014-08-17 10:16:57 +00:00
|
|
|
// Note that these DO NOT AddRef so you must not ->Release presets unless you manually AddRef them.
|
2018-12-16 22:06:01 +00:00
|
|
|
ShaderModule *GetVshaderPreset(VertexShaderPreset preset) { return vsPresets_[preset]; }
|
|
|
|
ShaderModule *GetFshaderPreset(FragmentShaderPreset preset) { return fsPresets_[preset]; }
|
2014-08-17 10:16:57 +00:00
|
|
|
|
2016-12-26 16:03:01 +00:00
|
|
|
// Resources
|
|
|
|
virtual Buffer *CreateBuffer(size_t size, uint32_t usageFlags) = 0;
|
2018-01-17 12:59:32 +00:00
|
|
|
// Does not take ownership over pointed-to initData. After this returns, can dispose of it.
|
2017-01-16 16:43:07 +00:00
|
|
|
virtual Texture *CreateTexture(const TextureDesc &desc) = 0;
|
2017-02-04 17:46:12 +00:00
|
|
|
// On some hardware, you might get a 24-bit depth buffer even though you only wanted a 16-bit one.
|
2017-02-06 10:26:24 +00:00
|
|
|
virtual Framebuffer *CreateFramebuffer(const FramebufferDesc &desc) = 0;
|
2017-01-17 17:31:44 +00:00
|
|
|
|
2017-02-07 17:16:52 +00:00
|
|
|
// Copies data from the CPU over into the buffer, at a specific offset. This does not change the size of the buffer and cannot write outside it.
|
2017-02-07 18:41:58 +00:00
|
|
|
virtual void UpdateBuffer(Buffer *buffer, const uint8_t *data, size_t offset, size_t size, UpdateBufferFlags flags) = 0;
|
2017-02-07 17:16:52 +00:00
|
|
|
|
2020-05-21 09:24:05 +00:00
|
|
|
virtual void CopyFramebufferImage(Framebuffer *src, int level, int x, int y, int z, Framebuffer *dst, int dstLevel, int dstX, int dstY, int dstZ, int width, int height, int depth, int channelBits, const char *tag) = 0;
|
|
|
|
virtual bool BlitFramebuffer(Framebuffer *src, int srcX1, int srcY1, int srcX2, int srcY2, Framebuffer *dst, int dstX1, int dstY1, int dstX2, int dstY2, int channelBits, FBBlitFilter filter, const char *tag) = 0;
|
|
|
|
virtual bool CopyFramebufferToMemorySync(Framebuffer *src, int channelBits, int x, int y, int w, int h, Draw::DataFormat format, void *pixels, int pixelStride, const char *tag) {
|
2017-10-10 12:26:35 +00:00
|
|
|
return false;
|
|
|
|
}
|
2018-06-16 20:47:51 +00:00
|
|
|
virtual DataFormat PreferredFramebufferReadbackFormat(Framebuffer *src) {
|
|
|
|
return DataFormat::R8G8B8A8_UNORM;
|
|
|
|
}
|
2017-02-04 17:46:12 +00:00
|
|
|
|
|
|
|
// These functions should be self explanatory.
|
2017-05-16 11:53:57 +00:00
|
|
|
// Binding a zero render target means binding the backbuffer.
|
2020-05-21 09:24:05 +00:00
|
|
|
virtual void BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPassInfo &rp, const char *tag) = 0;
|
2020-12-12 23:20:13 +00:00
|
|
|
virtual Framebuffer *GetCurrentRenderTarget() = 0;
|
2017-05-16 11:53:57 +00:00
|
|
|
|
2020-07-27 16:22:23 +00:00
|
|
|
// binding must be < MAX_TEXTURE_SLOTS (0, 1 are okay if it's 2).
|
2017-02-06 10:26:24 +00:00
|
|
|
virtual void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int attachment) = 0;
|
2017-02-04 17:46:12 +00:00
|
|
|
|
2022-08-16 09:47:38 +00:00
|
|
|
// deprecated, only used by D3D9
|
2017-11-18 19:17:17 +00:00
|
|
|
virtual uintptr_t GetFramebufferAPITexture(Framebuffer *fbo, int channelBits, int attachment) {
|
|
|
|
return 0;
|
|
|
|
}
|
2017-02-04 17:46:12 +00:00
|
|
|
|
2017-02-06 10:26:24 +00:00
|
|
|
virtual void GetFramebufferDimensions(Framebuffer *fbo, int *w, int *h) = 0;
|
2017-02-04 17:46:12 +00:00
|
|
|
|
2022-08-28 21:16:48 +00:00
|
|
|
// Could be useful in OpenGL ES to give hints about framebuffers on tiler GPUs
|
|
|
|
// using glInvalidateFramebuffer, although drivers are known to botch that so we currently don't use it.
|
|
|
|
// In Vulkan, this sets the LOAD_OP or the STORE_OP (depending on stage) of the current render pass instance to DONT_CARE.
|
|
|
|
// channels is a bitwise combination of FBChannel::COLOR, DEPTH and STENCIL.
|
|
|
|
virtual void InvalidateFramebuffer(FBInvalidationStage stage, uint32_t channels) {}
|
2017-05-16 14:00:34 +00:00
|
|
|
|
2016-12-26 16:03:01 +00:00
|
|
|
// Dynamic state
|
|
|
|
virtual void SetScissorRect(int left, int top, int width, int height) = 0;
|
|
|
|
virtual void SetViewports(int count, Viewport *viewports) = 0;
|
2016-12-27 14:52:03 +00:00
|
|
|
virtual void SetBlendFactor(float color[4]) = 0;
|
2022-07-24 14:31:02 +00:00
|
|
|
virtual void SetStencilParams(uint8_t refValue, uint8_t writeMask, uint8_t compareMask) = 0;
|
2014-08-17 13:02:43 +00:00
|
|
|
|
2016-12-26 16:03:01 +00:00
|
|
|
virtual void BindSamplerStates(int start, int count, SamplerState **state) = 0;
|
2016-12-25 19:54:37 +00:00
|
|
|
virtual void BindTextures(int start, int count, Texture **textures) = 0;
|
2021-08-08 05:22:11 +00:00
|
|
|
virtual void BindVertexBuffers(int start, int count, Buffer **buffers, const int *offsets) = 0;
|
2017-01-17 16:14:47 +00:00
|
|
|
virtual void BindIndexBuffer(Buffer *indexBuffer, int offset) = 0;
|
|
|
|
|
2017-02-08 11:26:48 +00:00
|
|
|
// Only supports a single dynamic uniform buffer, for maximum compatibility with the old APIs and ease of emulation.
|
|
|
|
// More modern methods will be added later.
|
|
|
|
virtual void UpdateDynamicUniformBuffer(const void *ub, size_t size) = 0;
|
|
|
|
|
2016-12-25 19:54:37 +00:00
|
|
|
void BindTexture(int stage, Texture *texture) {
|
2018-05-29 21:30:41 +00:00
|
|
|
Texture *textures[1] = { texture };
|
|
|
|
BindTextures(stage, 1, textures);
|
2014-08-17 13:02:43 +00:00
|
|
|
} // from sampler 0 and upwards
|
2014-08-17 10:16:57 +00:00
|
|
|
|
2020-08-21 22:30:29 +00:00
|
|
|
// Clear state cached within thin3d. Must be called after directly calling API functions.
|
|
|
|
// Note that framebuffer state (which framebuffer is bounds) may not be cached.
|
|
|
|
// Must not actually perform any API calls itself since this can be called when no framebuffer is bound for rendering.
|
|
|
|
virtual void InvalidateCachedState() = 0;
|
|
|
|
|
2016-12-26 10:16:59 +00:00
|
|
|
virtual void BindPipeline(Pipeline *pipeline) = 0;
|
|
|
|
|
2017-01-17 16:14:47 +00:00
|
|
|
virtual void Draw(int vertexCount, int offset) = 0;
|
2020-05-15 16:07:07 +00:00
|
|
|
virtual void DrawIndexed(int vertexCount, int offset) = 0; // Always 16-bit indices.
|
2016-12-26 16:03:01 +00:00
|
|
|
virtual void DrawUP(const void *vdata, int vertexCount) = 0;
|
2015-10-10 14:41:19 +00:00
|
|
|
|
2017-05-16 11:30:10 +00:00
|
|
|
// Frame management (for the purposes of sync and resource management, necessary with modern APIs). Default implementations here.
|
|
|
|
virtual void BeginFrame() {}
|
2020-07-13 21:11:52 +00:00
|
|
|
virtual void EndFrame() = 0;
|
2017-11-01 20:42:19 +00:00
|
|
|
virtual void WipeQueue() {}
|
2017-05-16 11:30:10 +00:00
|
|
|
|
2017-05-16 11:53:57 +00:00
|
|
|
// This should be avoided as much as possible, in favor of clearing when binding a render target, which is native
|
|
|
|
// on Vulkan.
|
2014-08-17 10:16:57 +00:00
|
|
|
virtual void Clear(int mask, uint32_t colorval, float depthVal, int stencilVal) = 0;
|
2017-05-16 11:53:57 +00:00
|
|
|
|
2014-08-17 13:29:50 +00:00
|
|
|
// Necessary to correctly flip scissor rectangles etc for OpenGL.
|
2017-12-12 14:04:46 +00:00
|
|
|
virtual void SetTargetSize(int w, int h) {
|
2014-08-17 13:29:50 +00:00
|
|
|
targetWidth_ = w;
|
|
|
|
targetHeight_ = h;
|
|
|
|
}
|
|
|
|
|
2016-12-25 17:52:05 +00:00
|
|
|
virtual std::string GetInfoString(InfoField info) const = 0;
|
2022-08-05 09:09:16 +00:00
|
|
|
virtual uint64_t GetNativeObject(NativeObject obj, void *srcObject = nullptr) = 0; // Most uses don't need an srcObject.
|
2017-02-05 19:05:03 +00:00
|
|
|
|
2017-03-05 19:30:39 +00:00
|
|
|
virtual void HandleEvent(Event ev, int width, int height, void *param1 = nullptr, void *param2 = nullptr) = 0;
|
2017-02-06 10:20:27 +00:00
|
|
|
|
2017-05-21 21:13:53 +00:00
|
|
|
// Flush state like scissors etc so the caller can do its own custom drawing.
|
|
|
|
virtual void FlushState() {}
|
|
|
|
|
2020-05-24 18:57:59 +00:00
|
|
|
virtual int GetCurrentStepId() const = 0;
|
|
|
|
|
2014-08-17 10:16:57 +00:00
|
|
|
protected:
|
2016-12-25 21:24:14 +00:00
|
|
|
ShaderModule *vsPresets_[VS_MAX_PRESET];
|
|
|
|
ShaderModule *fsPresets_[FS_MAX_PRESET];
|
2014-08-17 10:16:57 +00:00
|
|
|
|
2020-11-06 08:01:13 +00:00
|
|
|
ShaderLanguageDesc shaderLanguageDesc_;
|
|
|
|
|
2014-08-17 13:29:50 +00:00
|
|
|
int targetWidth_;
|
|
|
|
int targetHeight_;
|
2018-12-23 20:19:34 +00:00
|
|
|
|
|
|
|
Bugs bugs_;
|
2014-08-17 10:16:57 +00:00
|
|
|
};
|
|
|
|
|
2017-02-08 11:26:48 +00:00
|
|
|
extern const UniformBufferDesc UBPresetDesc;
|
|
|
|
|
|
|
|
// UBs for the preset shaders
|
|
|
|
|
|
|
|
struct VsTexColUB {
|
|
|
|
float WorldViewProj[16];
|
2022-02-11 14:12:52 +00:00
|
|
|
float tint;
|
|
|
|
float saturation;
|
|
|
|
float pad[2];
|
2017-02-08 11:26:48 +00:00
|
|
|
};
|
|
|
|
extern const UniformBufferDesc vsTexColBufDesc;
|
|
|
|
struct VsColUB {
|
|
|
|
float WorldViewProj[16];
|
2022-02-11 17:43:21 +00:00
|
|
|
float tint;
|
|
|
|
float saturation;
|
|
|
|
float pad[2];
|
2017-02-08 11:26:48 +00:00
|
|
|
};
|
|
|
|
extern const UniformBufferDesc vsColBufDesc;
|
|
|
|
|
2018-12-16 20:48:35 +00:00
|
|
|
// Useful utility for specifying a shader in multiple languages.
|
|
|
|
|
|
|
|
struct ShaderSource {
|
|
|
|
ShaderLanguage lang;
|
|
|
|
const char *src;
|
|
|
|
};
|
|
|
|
|
|
|
|
ShaderModule *CreateShader(DrawContext *draw, ShaderStage stage, const std::vector<ShaderSource> &sources);
|
|
|
|
|
2017-02-04 17:46:12 +00:00
|
|
|
} // namespace Draw
|