Project
Loading...
Searching...
No Matches
GPUDisplayBackend.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#ifndef GPUDISPLAYBACKEND_H
16#define GPUDISPLAYBACKEND_H
17
18#include "GPUCommonDef.h"
19#include "../utils/vecpod.h"
20#include <array>
21#include <cstddef>
22#include <memory>
23#include <vector>
24
25#if defined(GPUCA_DISPLAY_GL3W) && !defined(GPUCA_DISPLAY_OPENGL_CORE)
26#define GPUCA_DISPLAY_OPENGL_CORE
27#endif
28
29union hmm_mat4;
30
31namespace o2::gpu
32{
33class GPUDisplay;
34class GPUDisplayFrontend;
35class GPUDisplayMagneticField;
36struct GLfb;
38{
39 friend GPUDisplay;
40
41 public:
44
45 virtual int32_t ExtInit() { return 0; };
46 virtual bool CoreProfile() { return false; };
47 virtual uint32_t DepthBits() = 0;
48
49 typedef std::tuple<uint32_t, uint32_t, int32_t> vboList;
50
51 enum drawType {
52 POINTS = 0,
53 LINES = 1,
54 LINE_STRIP = 2
55 };
56
63
65 DrawArraysIndirectCommand(uint32_t a = 0, uint32_t b = 0, uint32_t c = 0, uint32_t d = 0) : count(a), instanceCount(b), first(c), baseInstance(d) {}
66 uint32_t count;
67 uint32_t instanceCount;
68
69 uint32_t first;
70 uint32_t baseInstance;
71 };
72
73 struct FontSymbol {
74 int32_t size[2];
75 int32_t offset[2];
76 int32_t advance;
77 };
78
79 virtual uint32_t drawVertices(const vboList& v, const drawType t) = 0;
80 virtual uint32_t drawField() { return 0; }
81 virtual void ActivateColor(std::array<float, 4>& color) = 0;
82 virtual void setQuality() {};
83 virtual void SetVSync(bool enable) {};
84 virtual bool backendNeedRedraw() { return true; }
85 virtual void setDepthBuffer() = 0;
86 virtual int32_t InitBackendA() = 0;
87 virtual void ExitBackendA() = 0;
88 int32_t InitBackend();
89 void ExitBackend();
90 virtual void loadDataToGPU(size_t totalVertizes) = 0;
91 virtual void prepareDraw(const hmm_mat4& proj, const hmm_mat4& view, bool requestScreenshot = false, bool toMixBuffer = false, float includeMixImage = 0.f) = 0;
92 virtual void finishDraw(bool doScreenshot, bool toMixBuffer = false, float includeMixImage = 0.f) = 0;
93 virtual void finishFrame(bool doScreenshot, bool toMixBuffer = false, float includeMixImage = 0.f) = 0;
94 virtual void prepareText() = 0;
95 virtual void finishText() = 0;
96 virtual void pointSizeFactor(float factor) = 0;
97 virtual void lineWidthFactor(float factor) = 0;
99 const char* backendName() const { return mBackendName; }
100 virtual void resizeScene(uint32_t width, uint32_t height) {}
101 virtual size_t needMultiVBO() { return 0; }
102 virtual void OpenGLPrint(const char* s, float x, float y, float* color, float scale) = 0;
103 static GPUDisplayBackend* getBackend(const char* type);
104 std::vector<char> getPixels();
105 virtual float getYFactor() const { return 1.0f; }
106 virtual int32_t getMaxMSAA() const { return 16; }
107
108 protected:
109 virtual void addFontSymbol(int32_t symbol, int32_t sizex, int32_t sizey, int32_t offsetx, int32_t offsety, int32_t advance, void* data) = 0;
110 virtual void initializeTextDrawing() = 0;
111
112 float getDownsampleFactor(bool screenshot = false);
114 bool smoothFont();
115
117 std::vector<int32_t> mIndirectSectorOffset;
121 std::vector<char> mScreenshotPixels;
122
123 int32_t mDownsampleFactor = 1;
124
125 uint32_t mRenderWidth = 0;
126 uint32_t mRenderHeight = 0;
127 uint32_t mScreenWidth = 0;
128 uint32_t mScreenHeight = 0;
129
131 const char* mBackendName = nullptr;
132
133 std::unique_ptr<GPUDisplayMagneticField> mMagneticFieldVisualization;
134};
135} // namespace o2::gpu
136
137#endif
uint32_t c
Definition RawData.h:2
virtual void addFontSymbol(int32_t symbol, int32_t sizex, int32_t sizey, int32_t offsetx, int32_t offsety, int32_t advance, void *data)=0
virtual float getYFactor() const
std::vector< char > getPixels()
virtual uint32_t drawVertices(const vboList &v, const drawType t)=0
virtual void finishFrame(bool doScreenshot, bool toMixBuffer=false, float includeMixImage=0.f)=0
vecpod< DrawArraysIndirectCommand > mCmdBuffer
virtual void prepareText()=0
const char * backendName() const
std::vector< int32_t > mIndirectSectorOffset
virtual void SetVSync(bool enable)
virtual int32_t getMaxMSAA() const
virtual void lineWidthFactor(float factor)=0
static GPUDisplayBackend * getBackend(const char *type)
virtual void prepareDraw(const hmm_mat4 &proj, const hmm_mat4 &view, bool requestScreenshot=false, bool toMixBuffer=false, float includeMixImage=0.f)=0
virtual void finishText()=0
virtual void ActivateColor(std::array< float, 4 > &color)=0
std::vector< char > mScreenshotPixels
virtual void resizeScene(uint32_t width, uint32_t height)
virtual void ExitBackendA()=0
virtual void initializeTextDrawing()=0
virtual void setDepthBuffer()=0
virtual int32_t InitBackendA()=0
backendTypes backendType() const
std::unique_ptr< GPUDisplayMagneticField > mMagneticFieldVisualization
virtual void finishDraw(bool doScreenshot, bool toMixBuffer=false, float includeMixImage=0.f)=0
virtual void loadDataToGPU(size_t totalVertizes)=0
float getDownsampleFactor(bool screenshot=false)
virtual void pointSizeFactor(float factor)=0
virtual uint32_t DepthBits()=0
std::tuple< uint32_t, uint32_t, int32_t > vboList
virtual void OpenGLPrint(const char *s, float x, float y, float *color, float scale)=0
GLint GLenum GLint x
Definition glcorearb.h:403
GLint GLsizei count
Definition glcorearb.h:399
GLsizeiptr size
Definition glcorearb.h:659
GLuint color
Definition glcorearb.h:1272
const GLdouble * v
Definition glcorearb.h:832
GLint GLsizei GLsizei height
Definition glcorearb.h:270
GLint GLsizei width
Definition glcorearb.h:270
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
GLboolean * data
Definition glcorearb.h:298
GLintptr offset
Definition glcorearb.h:660
GLboolean enable
Definition glcorearb.h:3991
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
DrawArraysIndirectCommand(uint32_t a=0, uint32_t b=0, uint32_t c=0, uint32_t d=0)
typename std::vector< T, vecpod_allocator< T > > vecpod
Definition vecpod.h:31