CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/GPU/Common/Draw2D.h
Views: 1401
1
#pragma once
2
3
#include "GPU/GPU.h"
4
#include "Common/GPU/Shader.h"
5
6
// For framebuffer copies and similar things that just require passthrough.
7
struct Draw2DVertex {
8
float x;
9
float y;
10
float u;
11
float v;
12
};
13
14
enum Draw2DShader {
15
DRAW2D_COPY_COLOR,
16
DRAW2D_COPY_DEPTH,
17
DRAW2D_ENCODE_R16_TO_DEPTH,
18
DRAW2D_565_TO_DEPTH,
19
DRAW2D_565_TO_DEPTH_DESWIZZLE,
20
DRAW2D_COPY_COLOR_RECT2LIN,
21
};
22
23
inline RasterChannel Draw2DSourceChannel(Draw2DShader shader) {
24
switch (shader) {
25
case DRAW2D_COPY_DEPTH:
26
return RASTER_DEPTH;
27
case DRAW2D_COPY_COLOR:
28
case DRAW2D_ENCODE_R16_TO_DEPTH:
29
case DRAW2D_565_TO_DEPTH:
30
case DRAW2D_565_TO_DEPTH_DESWIZZLE:
31
default:
32
return RASTER_COLOR;
33
}
34
}
35
36
struct Draw2DPipelineInfo {
37
const char *tag;
38
RasterChannel readChannel;
39
RasterChannel writeChannel;
40
Slice<SamplerDef> samplers;
41
};
42
43
extern const UniformDef g_draw2Duniforms[5];
44
45
struct Draw2DPipeline {
46
Draw::Pipeline *pipeline;
47
Draw2DPipelineInfo info;
48
char *code;
49
void Release() {
50
pipeline->Release();
51
delete[] code;
52
delete this;
53
}
54
};
55
56
class ShaderWriter;
57
58
class Draw2D {
59
public:
60
Draw2D(Draw::DrawContext *draw) : draw_(draw) {}
61
void DeviceLost();
62
void DeviceRestore(Draw::DrawContext *draw);
63
64
Draw2DPipeline *Create2DPipeline(std::function<Draw2DPipelineInfo(ShaderWriter &)> generate);
65
66
void DrawStrip2D(Draw::Texture *tex, const Draw2DVertex *verts, int vertexCount, bool linearFilter, Draw2DPipeline *pipeline, float texW = 0.0f, float texH = 0.0f, int scaleFactor = 0);
67
68
void Blit(Draw2DPipeline *pipeline, float srcX1, float srcY1, float srcX2, float srcY2, float dstX1, float dstY1, float dstX2, float dstY2, float srcWidth, float srcHeight, float dstWidth, float dstHeight, bool linear, int scaleFactor);
69
void Ensure2DResources();
70
71
private:
72
Draw::DrawContext *draw_;
73
74
Draw::SamplerState *draw2DSamplerLinear_ = nullptr;
75
Draw::SamplerState *draw2DSamplerNearest_ = nullptr;
76
Draw::ShaderModule *draw2DVs_ = nullptr;
77
};
78
79