8 #ifndef hifi_gpu_GLShared_h
9 #define hifi_gpu_GLShared_h
11 #include <gl/Config.h>
12 #include <gl/GLHelpers.h>
13 #include <gpu/Forward.h>
14 #include <gpu/Format.h>
15 #include <gpu/Context.h>
16 #include <QLoggingCategory>
18 Q_DECLARE_LOGGING_CATEGORY(gpugllogging)
19 Q_DECLARE_LOGGING_CATEGORY(trace_render_gpu_gl)
20 Q_DECLARE_LOGGING_CATEGORY(trace_render_gpu_gl_detail)
22 #if defined(__clang__)
23 #define BUFFER_OFFSET(bytes) (reinterpret_cast<GLvoid*>(bytes))
25 #define BUFFER_OFFSET(bytes) ((GLubyte*) nullptr + (bytes))
28 namespace gpu {
namespace gl {
36 gpu::Size getFreeDedicatedMemory();
37 ComparisonFunction comparisonFuncFromGL(GLenum func);
38 State::StencilOp stencilOpFromGL(GLenum stencilOp);
39 State::BlendOp blendOpFromGL(GLenum blendOp);
40 State::BlendArg blendArgFromGL(GLenum blendArg);
41 void getCurrentGLState(State::Data& state);
56 static const GLenum BLEND_OPS_TO_GL[State::NUM_BLEND_OPS] = {
59 GL_FUNC_REVERSE_SUBTRACT,
64 static const GLenum BLEND_ARGS_TO_GL[State::NUM_BLEND_ARGS] = {
68 GL_ONE_MINUS_SRC_COLOR,
70 GL_ONE_MINUS_SRC_ALPHA,
72 GL_ONE_MINUS_DST_ALPHA,
74 GL_ONE_MINUS_DST_COLOR,
75 GL_SRC_ALPHA_SATURATE,
77 GL_ONE_MINUS_CONSTANT_COLOR,
79 GL_ONE_MINUS_CONSTANT_ALPHA,
82 static const GLenum COMPARISON_TO_GL[gpu::NUM_COMPARISON_FUNCS] = {
93 static const GLenum PRIMITIVE_TO_GL[gpu::NUM_PRIMITIVES] = {
102 static const GLenum ELEMENT_TYPE_TO_GL[gpu::NUM_TYPES] = {
119 GL_INT_2_10_10_10_REV,
124 template <
typename GPUType>
125 struct GLObject :
public GPUObject {
127 GLObject(
const std::weak_ptr<GLBackend>& backend,
const GPUType& gpuObject, GLuint
id) : _gpuObject(gpuObject), _id(id), _backend(backend) {}
129 virtual ~GLObject() { }
131 const GPUType& _gpuObject;
134 const std::weak_ptr<GLBackend> _backend;
144 class GLTextureTransferEngine;
145 using GLTextureTransferEnginePointer = std::shared_ptr<GLTextureTransferEngine>;