blob: 745f5720d3d4119d83f71a722f8b77ce638712f7 [file] [log] [blame]
José Fonseca1b3d3752011-07-15 10:15:19 +01001/**************************************************************************
2 *
3 * Copyright 2011 Jose Fonseca
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 *
24 **************************************************************************/
25
Jose Fonseca9653f952015-05-19 16:32:43 +010026#pragma once
José Fonseca1b3d3752011-07-15 10:15:19 +010027
28
José Fonseca219c9f22012-11-03 10:13:17 +000029#include "glimports.hpp"
30
Jose Fonseca9ed64622016-04-04 13:36:12 +010031#include "glfeatures.hpp"
José Fonsecab0c59722015-01-05 20:45:41 +000032
Danylo Piliaiev9f18e5d2019-07-03 11:12:50 +030033#include "glmemshadow.hpp"
34
35#include <map>
36#include <vector>
37#include <memory>
José Fonseca1b3d3752011-07-15 10:15:19 +010038
Jose Fonseca27b8d812016-05-13 07:09:09 -070039void APIENTRY _fake_glScissor(GLint x, GLint y, GLsizei width, GLsizei height);
40void APIENTRY _fake_glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
41
José Fonseca1b3d3752011-07-15 10:15:19 +010042namespace gltrace {
43
Robert Tarasov6ccf5bb2020-01-10 12:31:25 -080044class ShareableContextResources {
45public:
46 std::map<GLint, std::unique_ptr<GLMemoryShadow>> bufferToShadowMemory;
47
48 std::vector<GLMemoryShadow*> dirtyShadows;
49};
José Fonseca1b3d3752011-07-15 10:15:19 +010050
Imre Deaka150c4a2012-05-07 09:10:26 +030051class Context {
52public:
Jose Fonseca9ed64622016-04-04 13:36:12 +010053 glfeatures::Profile profile;
Jose Fonseca8d6653a2016-04-04 15:42:25 +010054 glfeatures::Extensions extensions;
55 glfeatures::Features features;
56
Jose Fonseca830c0be2016-05-01 19:46:34 +010057 bool user_arrays = false;
Jose Fonseca830c0be2016-05-01 19:46:34 +010058 bool userArraysOnBegin = false;
59 unsigned retain_count = 0;
José Fonseca219c9f22012-11-03 10:13:17 +000060
José Fonseca1e3950d2013-06-12 23:13:09 +010061 // Whether it has been bound before
Jose Fonseca830c0be2016-05-01 19:46:34 +010062 bool bound = false;
Jose Fonsecafc0ce012016-05-01 19:51:05 +010063 // Whether it has been bound to a drawable
64 bool boundDrawable = false;
José Fonseca1e3950d2013-06-12 23:13:09 +010065
Jose Fonseca97d22a72016-05-10 04:47:08 -070066 // whether glLockArraysEXT() has ever been called
Jose Fonseca16385192016-05-13 08:55:25 -070067 GLuint lockedArrayCount = 0;
Jose Fonseca97d22a72016-05-10 04:47:08 -070068
Robert Tarasov6ccf5bb2020-01-10 12:31:25 -080069 // the data which can be shared between shared contexts
70 std::shared_ptr<ShareableContextResources> sharedRes;
Danylo Piliaiev9f18e5d2019-07-03 11:12:50 +030071
José Fonseca5c298db2012-07-11 12:14:31 +010072 Context(void) :
Robert Tarasov6ccf5bb2020-01-10 12:31:25 -080073 profile(glfeatures::API_GL, 1, 0),
74 sharedRes(std::make_shared<ShareableContextResources>())
José Fonseca5c298db2012-07-11 12:14:31 +010075 { }
José Fonsecaf028a8f2012-02-15 23:33:35 +000076};
Imre Deaka150c4a2012-05-07 09:10:26 +030077
78void
Robert Tarasov6ccf5bb2020-01-10 12:31:25 -080079createContext(uintptr_t context_id, uintptr_t shared_context_id);
Imre Deaka150c4a2012-05-07 09:10:26 +030080
Imre Deaka150c4a2012-05-07 09:10:26 +030081void
82retainContext(uintptr_t context_id);
83
84bool
85releaseContext(uintptr_t context_id);
86
87void
88setContext(uintptr_t context_id);
89
90void
91clearContext(void);
92
93gltrace::Context *
José Fonsecaf028a8f2012-02-15 23:33:35 +000094getContext(void);
95
José Fonsecaa08d2752011-08-25 13:26:43 +010096const GLubyte *
José Fonseca632a78d2012-04-19 07:18:59 +010097_glGetString_override(GLenum name);
José Fonseca1b3d3752011-07-15 10:15:19 +010098
José Fonsecaa08d2752011-08-25 13:26:43 +010099void
José Fonseca632a78d2012-04-19 07:18:59 +0100100_glGetIntegerv_override(GLenum pname, GLint *params);
José Fonseca1b3d3752011-07-15 10:15:19 +0100101
José Fonsecaa08d2752011-08-25 13:26:43 +0100102const GLubyte *
José Fonseca632a78d2012-04-19 07:18:59 +0100103_glGetStringi_override(GLenum name, GLuint index);
José Fonseca1b3d3752011-07-15 10:15:19 +0100104
105
106} /* namespace gltrace */