12 #ifndef hifi_gpu_Backend_h
13 #define hifi_gpu_Backend_h
15 #include <GLMHelpers.h>
20 #include "Framebuffer.h"
29 int _ISNumFormatChanges = 0;
30 int _ISNumInputBufferChanges = 0;
31 int _ISNumIndexBufferChanges = 0;
33 int _RSNumResourceBufferBounded = 0;
34 int _RSNumTextureBounded = 0;
35 int _RSAmountTextureMemoryBounded = 0;
37 int _DSNumAPIDrawcalls = 0;
38 int _DSNumDrawcalls = 0;
39 int _DSNumTriangles = 0;
41 int _PSNumSetPipelines = 0;
44 ContextStats(
const ContextStats& stats) =
default;
46 void evalDelta(
const ContextStats& begin,
const ContextStats& end);
53 virtual void shutdown() {}
54 virtual const std::string& getVersion()
const = 0;
56 void setStereoState(
const StereoState& stereo);
58 virtual void executeFrame(
const FramePointer& frame) = 0;
59 virtual void render(
const Batch& batch) = 0;
60 virtual void syncCache() = 0;
61 virtual void syncProgram(
const gpu::ShaderPointer& program) = 0;
62 virtual void recycle()
const = 0;
63 virtual void downloadFramebuffer(
const FramebufferPointer& srcFramebuffer,
const Vec4i& region, QImage& destImage) = 0;
64 virtual void updatePresentFrame(
const Mat4& correction =
Mat4(),
bool primary =
true) = 0;
66 virtual bool supportedTextureFormat(
const gpu::Element& format)
const = 0;
69 #include "TransformCamera_shared.slh"
71 class TransformCamera :
public _TransformCamera {
73 const Backend::TransformCamera& recomputeDerived(
const Transform& view,
const Transform& previousView,
const Mat4& previousProjection)
const;
75 TransformCamera getMonoCamera(
bool isSkybox,
const Transform& view, Transform previousView,
Mat4 previousProjection, Vec2 normalizedJitter)
const;
77 TransformCamera getEyeCamera(
int eye,
const StereoState& stereo,
const StereoState& prevStereo,
const Transform& view,
const Transform& previousView,
78 Vec2 normalizedJitter)
const;
81 template <
typename T,
typename U>
82 static void setGPUObject(
const U&
object, T* gpuObject) {
83 object.gpuObject.setGPUObject(gpuObject);
85 template <
typename T,
typename U>
86 static T* getGPUObject(
const U&
object) {
87 return reinterpret_cast<T*
>(
object.gpuObject.getGPUObject());
90 void resetStats()
const { _stats = ContextStats(); }
91 void getStats(ContextStats& stats)
const { stats = _stats; }
93 virtual bool isTextureManagementSparseEnabled()
const = 0;
97 static ContextMetricSize freeGPUMemSize;
99 static ContextMetricCount bufferCount;
100 static ContextMetricSize bufferGPUMemSize;
102 static ContextMetricCount textureResidentCount;
103 static ContextMetricCount textureFramebufferCount;
104 static ContextMetricCount textureResourceCount;
105 static ContextMetricCount textureExternalCount;
107 static ContextMetricSize textureResidentGPUMemSize;
108 static ContextMetricSize textureFramebufferGPUMemSize;
109 static ContextMetricSize textureResourceGPUMemSize;
110 static ContextMetricSize textureExternalGPUMemSize;
112 static ContextMetricCount texturePendingGPUTransferCount;
113 static ContextMetricSize texturePendingGPUTransferMemSize;
114 static ContextMetricSize textureResourcePopulatedGPUMemSize;
115 static ContextMetricSize textureResourceIdealGPUMemSize;
118 virtual bool isStereo()
const {
119 return _stereo.isStereo();
122 void getStereoProjections(mat4* eyeProjections)
const {
123 for (
int i = 0; i < 2; ++i) {
124 eyeProjections[i] = _stereo._eyeProjections[i];
128 void getStereoViews(mat4* eyeViews)
const {
129 for (
int i = 0; i < 2; ++i) {
130 eyeViews[i] = _stereo._eyeViews[i];
134 friend class Context;
135 mutable ContextStats _stats;
137 StereoState _prevStereo;
Provides the Mat4 scripting interface.
Definition: Mat4.h:44