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
62
64 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) {}
65 uint32_t count;
66 uint32_t instanceCount;
67
68 uint32_t first;
69 uint32_t baseInstance;
70 };
71
72 struct FontSymbol {
73 int32_t size[2];
74 int32_t offset[2];
75 int32_t advance;
76 };
77
78 virtual uint32_t drawVertices(const vboList& v, const drawType t) = 0;
79 virtual uint32_t drawField() { return 0; }
80 virtual void ActivateColor(std::array<float, 4>& color) = 0;
81 virtual void setQuality() {};
82 virtual void SetVSync(bool enable) {};
83 virtual bool backendNeedRedraw() { return true; }
84 virtual void setDepthBuffer() = 0;
85 virtual int32_t InitBackendA() = 0;
86 virtual void ExitBackendA() = 0;
87 int32_t InitBackend();
88 void ExitBackend();
89 virtual void loadDataToGPU(size_t totalVertizes) = 0;
90 virtual void prepareDraw(const hmm_mat4& proj, const hmm_mat4& view, bool requestScreenshot = false, bool toMixBuffer = false, float includeMixImage = 0.f) = 0;
91 virtual void finishDraw(bool doScreenshot, bool toMixBuffer = false, float includeMixImage = 0.f) = 0;
92 virtual void finishFrame(bool doScreenshot, bool toMixBuffer = false, float includeMixImage = 0.f) = 0;
93 virtual void prepareText() = 0;
94 virtual void finishText() = 0;
95 virtual void pointSizeFactor(float factor) = 0;
96 virtual void lineWidthFactor(float factor) = 0;
98 const char* backendName() const { return mBackendName; }
99 virtual void resizeScene(uint32_t width, uint32_t height) {}
100 virtual size_t needMultiVBO() { return 0; }
101 virtual void OpenGLPrint(const char* s, float x, float y, float* color, float scale) = 0;
102 static GPUDisplayBackend* getBackend(const char* type);
103 std::vector<char> getPixels();
104 virtual float getYFactor() const { return 1.0f; }
105 virtual int32_t getMaxMSAA() const { return 16; }
106
107 protected:
108 virtual void addFontSymbol(int32_t symbol, int32_t sizex, int32_t sizey, int32_t offsetx, int32_t offsety, int32_t advance, void* data) = 0;
109 virtual void initializeTextDrawing() = 0;
110
111 float getDownsampleFactor(bool screenshot = false);
113 bool smoothFont();
114
116 std::vector<int32_t> mIndirectSectorOffset;
120 std::vector<char> mScreenshotPixels;
121
122 int32_t mDownsampleFactor = 1;
123
124 uint32_t mRenderWidth = 0;
125 uint32_t mRenderHeight = 0;
126 uint32_t mScreenWidth = 0;
127 uint32_t mScreenHeight = 0;
128
130 const char* mBackendName = nullptr;
131
132 std::unique_ptr<GPUDisplayMagneticField> mMagneticFieldVisualization;
133};
134} // namespace o2::gpu
135
136#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