CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/GPU/GLES/DrawEngineGLES.h
Views: 1401
// Copyright (c) 2012- PPSSPP Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official git repository and contact information can be found at15// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.1617#pragma once1819#include "Common/Data/Collections/Hashmaps.h"20#include "Common/GPU/OpenGL/GLCommon.h"21#include "Common/GPU/OpenGL/GLRenderManager.h"2223#include "GPU/GPUState.h"24#include "GPU/Common/GPUDebugInterface.h"25#include "GPU/Common/IndexGenerator.h"26#include "GPU/Common/VertexDecoderCommon.h"27#include "GPU/Common/DrawEngineCommon.h"28#include "GPU/Common/GPUStateUtils.h"29#include "GPU/Common/FragmentShaderGenerator.h"3031class LinkedShader;32class ShaderManagerGLES;33class TextureCacheGLES;34class FramebufferManagerGLES;35class FramebufferManagerCommon;36class TextureCacheCommon;37class FragmentTestCacheGLES;38struct TransformedVertex;3940struct DecVtxFormat;4142class TessellationDataTransferGLES : public TessellationDataTransfer {43private:44GLRTexture *data_tex[3]{};45int prevSizeU = 0, prevSizeV = 0;46int prevSizeWU = 0, prevSizeWV = 0;47GLRenderManager *renderManager_;48public:49TessellationDataTransferGLES(GLRenderManager *renderManager)50: renderManager_(renderManager) { }51~TessellationDataTransferGLES() {52EndFrame();53}54// Send spline/bezier's control points and weights to vertex shader through floating point texture.55void SendDataToShader(const SimpleVertex *const *points, int size_u, int size_v, u32 vertType, const Spline::Weight2D &weights) override;56void EndFrame(); // Queues textures for deletion.57};5859// Handles transform, lighting and drawing.60class DrawEngineGLES : public DrawEngineCommon {61public:62DrawEngineGLES(Draw::DrawContext *draw);63~DrawEngineGLES();6465void SetShaderManager(ShaderManagerGLES *shaderManager) {66shaderManager_ = shaderManager;67}68void SetTextureCache(TextureCacheGLES *textureCache) {69textureCache_ = textureCache;70}71void SetFramebufferManager(FramebufferManagerGLES *fbManager) {72framebufferManager_ = fbManager;73}74void SetFragmentTestCache(FragmentTestCacheGLES *testCache) {75fragmentTestCache_ = testCache;76}7778void DeviceLost() override;79void DeviceRestore(Draw::DrawContext *draw) override;8081void ClearTrackedVertexArrays() override {}8283void BeginFrame();84void EndFrame();8586// So that this can be inlined87void Flush() {88if (!numDrawVerts_)89return;90DoFlush();91}9293void FinishDeferred() {94if (!numDrawVerts_)95return;96DoFlush();97}9899void DispatchFlush() override {100if (!numDrawVerts_)101return;102Flush();103}104105void ClearInputLayoutMap();106107static bool SupportsHWTessellation() ;108109protected:110bool UpdateUseHWTessellation(bool enable) const override;111112private:113void Invalidate(InvalidationCallbackFlags flags);114115void InitDeviceObjects();116void DestroyDeviceObjects();117118void DoFlush();119void ApplyDrawState(int prim);120void ApplyDrawStateLate(bool setStencil, int stencilValue);121122GLRInputLayout *SetupDecFmtForDraw(const DecVtxFormat &decFmt);123124struct FrameData {125GLPushBuffer *pushVertex;126GLPushBuffer *pushIndex;127};128FrameData frameData_[GLRenderManager::MAX_INFLIGHT_FRAMES];129130DenseHashMap<uint32_t, GLRInputLayout *> inputLayoutMap_;131132GLRInputLayout *softwareInputLayout_ = nullptr;133GLRenderManager *render_;134135// Other136ShaderManagerGLES *shaderManager_ = nullptr;137TextureCacheGLES *textureCache_ = nullptr;138FramebufferManagerGLES *framebufferManager_ = nullptr;139FragmentTestCacheGLES *fragmentTestCache_ = nullptr;140Draw::DrawContext *draw_;141142// Need to preserve the scissor for use when clearing.143ViewportAndScissor vpAndScissor_{};144// Need to preserve writemask, easiest way.145GenericStencilFuncState stencilState_{};146147int bufferDecimationCounter_ = 0;148int lastRenderStepId_ = -1;149150// Hardware tessellation151TessellationDataTransferGLES *tessDataTransferGLES;152};153154155