Welcome to mirror list, hosted at ThFree Co, Russian Federation.

render.h « include - github.com/dosbox-staging/dosbox-staging.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7f38b2bc74140ecd8d237d8edc1f705e903a31d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
 *  Copyright (C) 2002-2021  The DOSBox Team
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifndef DOSBOX_RENDER_H
#define DOSBOX_RENDER_H

// 0: complex scalers off, scaler cache off, some simple scalers off, memory requirements reduced
// 1: complex scalers off, scaler cache off, all simple scalers on
// 2: complex scalers off, scaler cache on
// 3: complex scalers on
#define RENDER_USE_ADVANCED_SCALERS 3

#include <deque>
#include <string>

#include "../src/gui/render_scalers.h"

#define RENDER_SKIP_CACHE 16
// Enable this for scalers to support 0 input for empty lines
//#define RENDER_NULL_INPUT

struct RenderPal_t {
	struct {
		uint8_t red    = 0;
		uint8_t green  = 0;
		uint8_t blue   = 0;
		uint8_t unused = 0;
	} rgb[256] = {};

	union {
		uint16_t b16[256];
		uint32_t b32[256] = {};
	} lut = {};

	bool changed          = false;
	uint8_t modified[256] = {};
	uint32_t first        = 0;
	uint32_t last         = 0;
};

struct Render_t {
	struct {
		uint32_t width  = 0;
		uint32_t start  = 0;
		uint32_t height = 0;
		unsigned bpp    = 0;
		bool dblw       = false;
		bool dblh       = false;
		double ratio    = 0;
		double fps      = 0;
	} src = {};

	struct {
		int count      = 0;
		int max        = 0;
		uint32_t index = 0;

		uint8_t hadSkip[RENDER_SKIP_CACHE] = {};
	} frameskip = {};

	struct {
		uint32_t size = 0;

		scalerMode_t inMode  = {};
		scalerMode_t outMode = {};
		scalerOperation_t op = {};

		bool clearCache = false;
		bool forced     = false;

		ScalerLineHandler_t lineHandler       = nullptr;
		ScalerLineHandler_t linePalHandler    = nullptr;
		ScalerComplexHandler_t complexHandler = nullptr;

		uint32_t blocks     = 0;
		uint32_t lastBlock  = 0;
		int outPitch        = 0;
		uint8_t *outWrite   = nullptr;
		uint32_t cachePitch = 0;
		uint8_t *cacheRead  = nullptr;
		uint32_t inHeight   = 0;
		uint32_t inLine     = 0;
		uint32_t outLine    = 0;
	} scale = {};

#if C_OPENGL
	struct {
		std::string filename      = {};
		std::string source        = {};
		bool use_srgb_texture     = false;
		bool use_srgb_framebuffer = false;
	} shader = {};
#endif

	RenderPal_t pal = {};

	bool updating  = false;
	bool active    = false;
	bool aspect    = true;
	bool fullFrame = true;
};

extern Render_t render;
extern ScalerLineHandler_t RENDER_DrawLine;

std::deque<std::string> RENDER_InventoryShaders();

void RENDER_SetSize(uint32_t width, uint32_t height, unsigned bpp, double fps,
                    double ratio, bool dblw, bool dblh);

bool RENDER_StartUpdate(void);
void RENDER_EndUpdate(bool abort);
void RENDER_InitShaderSource([[maybe_unused]] Section *sec);
void RENDER_SetPal(uint8_t entry, uint8_t red, uint8_t green, uint8_t blue);

#if C_OPENGL
bool RENDER_UseSRGBTexture();
bool RENDER_UseSRGBFramebuffer();
#endif

#endif