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/FragmentTestCacheGLES.h
Views: 1401
// Copyright (c) 2014- 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 <map>20#include "Common/CommonTypes.h"21#include "GPU/GLES/TextureCacheGLES.h"2223#include "GPU/ge_constants.h"2425struct FragmentTestID {26union {27struct {28u32 alpha;29u32 colorRefFunc;30u32 colorMask;31};32u32 d[3];33};3435bool operator < (const FragmentTestID &other) const {36for (size_t i = 0; i < sizeof(d) / sizeof(u32); i++) {37if (d[i] < other.d[i])38return true;39if (d[i] > other.d[i])40return false;41}42return false;43}44bool operator == (const FragmentTestID &other) const {45for (size_t i = 0; i < sizeof(d) / sizeof(u32); i++) {46if (d[i] != other.d[i])47return false;48}49return true;50}51};5253struct FragmentTestTexture {54GLRTexture *texture;55int lastFrame;56};5758class FragmentTestCacheGLES {59public:60FragmentTestCacheGLES(Draw::DrawContext *draw);61~FragmentTestCacheGLES();6263void SetTextureCache(TextureCacheGLES *tc) {64textureCache_ = tc;65}6667void BindTestTexture(int slot);6869void DeviceLost() {70Clear(false);71render_ = nullptr;72}73void DeviceRestore(Draw::DrawContext *draw);74void Clear(bool deleteThem = true);75void Decimate();7677private:7879GLRTexture *CreateTestTexture(const GEComparison funcs[4], const u8 refs[4], const u8 masks[4], const bool valid[4]);80static FragmentTestID GenerateTestID() ;8182GLRenderManager *render_;83TextureCacheGLES *textureCache_;8485std::map<FragmentTestID, FragmentTestTexture> cache_;86GLRTexture *lastTexture_ = nullptr;87int decimationCounter_ = 0;88};899091