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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
//
// Copyright 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Context9:
// D3D9-specific functionality associated with a GL Context.
//
#include "libANGLE/renderer/d3d/d3d9/Context9.h"
#include "common/string_utils.h"
#include "libANGLE/renderer/d3d/CompilerD3D.h"
#include "libANGLE/renderer/d3d/ShaderD3D.h"
#include "libANGLE/renderer/d3d/ProgramD3D.h"
#include "libANGLE/renderer/d3d/RenderbufferD3D.h"
#include "libANGLE/renderer/d3d/SamplerD3D.h"
#include "libANGLE/renderer/d3d/TextureD3D.h"
#include "libANGLE/renderer/d3d/d3d9/Buffer9.h"
#include "libANGLE/renderer/d3d/d3d9/Fence9.h"
#include "libANGLE/renderer/d3d/d3d9/Framebuffer9.h"
#include "libANGLE/renderer/d3d/d3d9/Query9.h"
#include "libANGLE/renderer/d3d/d3d9/Renderer9.h"
#include "libANGLE/renderer/d3d/d3d9/StateManager9.h"
#include "libANGLE/renderer/d3d/d3d9/VertexArray9.h"
namespace rx
{
Context9::Context9(const gl::ContextState &state, Renderer9 *renderer)
: ContextImpl(state), mRenderer(renderer)
{
}
Context9::~Context9()
{
}
gl::Error Context9::initialize()
{
return gl::NoError();
}
CompilerImpl *Context9::createCompiler()
{
return new CompilerD3D(SH_HLSL_3_0_OUTPUT);
}
ShaderImpl *Context9::createShader(const gl::ShaderState &data)
{
return new ShaderD3D(data, mRenderer->getWorkarounds());
}
ProgramImpl *Context9::createProgram(const gl::ProgramState &data)
{
return new ProgramD3D(data, mRenderer);
}
FramebufferImpl *Context9::createFramebuffer(const gl::FramebufferState &data)
{
return new Framebuffer9(data, mRenderer);
}
TextureImpl *Context9::createTexture(const gl::TextureState &state)
{
switch (state.getTarget())
{
case GL_TEXTURE_2D:
return new TextureD3D_2D(state, mRenderer);
case GL_TEXTURE_CUBE_MAP:
return new TextureD3D_Cube(state, mRenderer);
case GL_TEXTURE_EXTERNAL_OES:
return new TextureD3D_External(state, mRenderer);
default:
UNREACHABLE();
}
return nullptr;
}
RenderbufferImpl *Context9::createRenderbuffer()
{
return new RenderbufferD3D(mRenderer);
}
BufferImpl *Context9::createBuffer(const gl::BufferState &state)
{
return new Buffer9(state, mRenderer);
}
VertexArrayImpl *Context9::createVertexArray(const gl::VertexArrayState &data)
{
return new VertexArray9(data);
}
QueryImpl *Context9::createQuery(GLenum type)
{
return new Query9(mRenderer, type);
}
FenceNVImpl *Context9::createFenceNV()
{
return new FenceNV9(mRenderer);
}
FenceSyncImpl *Context9::createFenceSync()
{
// D3D9 doesn't support ES 3.0 and its sync objects.
UNREACHABLE();
return nullptr;
}
TransformFeedbackImpl *Context9::createTransformFeedback(const gl::TransformFeedbackState &state)
{
UNREACHABLE();
return nullptr;
}
SamplerImpl *Context9::createSampler()
{
return new SamplerD3D();
}
std::vector<PathImpl *> Context9::createPaths(GLsizei)
{
return std::vector<PathImpl *>();
}
gl::Error Context9::flush()
{
return mRenderer->flush();
}
gl::Error Context9::finish()
{
return mRenderer->finish();
}
gl::Error Context9::drawArrays(GLenum mode, GLint first, GLsizei count)
{
return mRenderer->genericDrawArrays(this, mode, first, count, 1);
}
gl::Error Context9::drawArraysInstanced(GLenum mode,
GLint first,
GLsizei count,
GLsizei instanceCount)
{
return mRenderer->genericDrawArrays(this, mode, first, count, instanceCount);
}
gl::Error Context9::drawElements(GLenum mode,
GLsizei count,
GLenum type,
const GLvoid *indices,
const gl::IndexRange &indexRange)
{
return mRenderer->genericDrawElements(this, mode, count, type, indices, 1, indexRange);
}
gl::Error Context9::drawElementsInstanced(GLenum mode,
GLsizei count,
GLenum type,
const GLvoid *indices,
GLsizei instances,
const gl::IndexRange &indexRange)
{
return mRenderer->genericDrawElements(this, mode, count, type, indices, instances, indexRange);
}
gl::Error Context9::drawRangeElements(GLenum mode,
GLuint start,
GLuint end,
GLsizei count,
GLenum type,
const GLvoid *indices,
const gl::IndexRange &indexRange)
{
return mRenderer->genericDrawElements(this, mode, count, type, indices, 1, indexRange);
}
GLenum Context9::getResetStatus()
{
return mRenderer->getResetStatus();
}
std::string Context9::getVendorString() const
{
return mRenderer->getVendorString();
}
std::string Context9::getRendererDescription() const
{
return mRenderer->getRendererDescription();
}
void Context9::insertEventMarker(GLsizei length, const char *marker)
{
auto optionalString = angle::WidenString(static_cast<size_t>(length), marker);
if (optionalString.valid())
{
mRenderer->getAnnotator()->setMarker(optionalString.value().data());
}
}
void Context9::pushGroupMarker(GLsizei length, const char *marker)
{
auto optionalString = angle::WidenString(static_cast<size_t>(length), marker);
if (optionalString.valid())
{
mRenderer->getAnnotator()->beginEvent(optionalString.value().data());
}
}
void Context9::popGroupMarker()
{
mRenderer->getAnnotator()->endEvent();
}
void Context9::syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits)
{
mRenderer->getStateManager()->syncState(state, dirtyBits);
}
GLint Context9::getGPUDisjoint()
{
return mRenderer->getGPUDisjoint();
}
GLint64 Context9::getTimestamp()
{
return mRenderer->getTimestamp();
}
void Context9::onMakeCurrent(const gl::ContextState &data)
{
}
const gl::Caps &Context9::getNativeCaps() const
{
return mRenderer->getNativeCaps();
}
const gl::TextureCapsMap &Context9::getNativeTextureCaps() const
{
return mRenderer->getNativeTextureCaps();
}
const gl::Extensions &Context9::getNativeExtensions() const
{
return mRenderer->getNativeExtensions();
}
const gl::Limitations &Context9::getNativeLimitations() const
{
return mRenderer->getNativeLimitations();
}
} // namespace rx
|