Commit 44462cd6 by Geoff Lang Committed by Commit Bot

D3D: Use the ProgramD3D::GetExecutableTask context for loading program binaries

ProgramD3D::GetExecutableTask is a d3d::Context type itself so that errors can be recorded in a thread-safe maner. Use the task context when loading program binaries in ProgramD3D. Fix up incorrect casts in RendererD3D::loadExecutable in both D3D9 and D3D11 backends to stop incorrectly assuming the context type. BUG=962439 Change-Id: I5b29372a7254f709e1bbb67ee322ef4109f73e48 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1630294Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent ce9be8c7
......@@ -839,16 +839,9 @@ gl::RangeUI ProgramD3D::getUsedImageRange(gl::ShaderType type, bool readonly) co
class ProgramD3D::LoadBinaryTask : public ProgramD3D::GetExecutableTask
{
public:
LoadBinaryTask(const gl::Context *context,
ProgramD3D *program,
gl::BinaryInputStream *stream,
gl::InfoLog &infoLog)
: ProgramD3D::GetExecutableTask(program),
mContext(context),
mProgram(program),
mInfoLog(infoLog)
{
ASSERT(mContext);
LoadBinaryTask(ProgramD3D *program, gl::BinaryInputStream *stream, gl::InfoLog &infoLog)
: ProgramD3D::GetExecutableTask(program), mProgram(program), mInfoLog(infoLog)
{
ASSERT(mProgram);
ASSERT(stream);
......@@ -871,11 +864,10 @@ class ProgramD3D::LoadBinaryTask : public ProgramD3D::GetExecutableTask
}
gl::BinaryInputStream stream(mStreamData.data(), mStreamData.size());
return mProgram->loadBinaryShaderExecutables(mContext, &stream, mInfoLog);
return mProgram->loadBinaryShaderExecutables(this, &stream, mInfoLog);
}
private:
const gl::Context *mContext;
ProgramD3D *mProgram;
gl::InfoLog &mInfoLog;
......@@ -887,11 +879,10 @@ class ProgramD3D::LoadBinaryLinkEvent final : public LinkEvent
{
public:
LoadBinaryLinkEvent(std::shared_ptr<WorkerThreadPool> workerPool,
const gl::Context *context,
ProgramD3D *program,
gl::BinaryInputStream *stream,
gl::InfoLog &infoLog)
: mTask(std::make_shared<ProgramD3D::LoadBinaryTask>(context, program, stream, infoLog)),
: mTask(std::make_shared<ProgramD3D::LoadBinaryTask>(program, stream, infoLog)),
mWaitableEvent(angle::WorkerThreadPool::PostWorkerTask(workerPool, mTask))
{}
......@@ -1109,11 +1100,11 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context,
stream->readString(&mGeometryShaderPreamble);
return std::make_unique<LoadBinaryLinkEvent>(context->getWorkerThreadPool(), context, this,
stream, infoLog);
return std::make_unique<LoadBinaryLinkEvent>(context->getWorkerThreadPool(), this, stream,
infoLog);
}
angle::Result ProgramD3D::loadBinaryShaderExecutables(const gl::Context *context,
angle::Result ProgramD3D::loadBinaryShaderExecutables(d3d::Context *contextD3D,
gl::BinaryInputStream *stream,
gl::InfoLog &infoLog)
{
......@@ -1121,8 +1112,6 @@ angle::Result ProgramD3D::loadBinaryShaderExecutables(const gl::Context *context
bool separateAttribs = (mState.getTransformFeedbackBufferMode() == GL_SEPARATE_ATTRIBS);
d3d::Context *contextD3D = GetImplAs<ContextD3D>(context);
const unsigned int vertexShaderCount = stream->readInt<unsigned int>();
for (unsigned int vertexShaderIndex = 0; vertexShaderIndex < vertexShaderCount;
vertexShaderIndex++)
......
......@@ -479,7 +479,7 @@ class ProgramD3D : public ProgramImpl
std::unique_ptr<LinkEvent> compileComputeExecutable(const gl::Context *context,
gl::InfoLog &infoLog);
angle::Result loadBinaryShaderExecutables(const gl::Context *context,
angle::Result loadBinaryShaderExecutables(d3d::Context *contextD3D,
gl::BinaryInputStream *stream,
gl::InfoLog &infoLog);
......
......@@ -2715,15 +2715,13 @@ angle::Result Renderer11::loadExecutable(d3d::Context *context,
{
ShaderData shaderData(function, length);
Context11 *context11 = static_cast<Context11 *>(context);
switch (type)
{
case gl::ShaderType::Vertex:
{
d3d11::VertexShader vertexShader;
d3d11::GeometryShader streamOutShader;
ANGLE_TRY(allocateResource(context11, shaderData, &vertexShader));
ANGLE_TRY(allocateResource(context, shaderData, &vertexShader));
if (!streamOutVaryings.empty())
{
......@@ -2743,8 +2741,7 @@ angle::Result Renderer11::loadExecutable(d3d::Context *context,
soDeclaration.push_back(entry);
}
ANGLE_TRY(
allocateResource(context11, shaderData, &soDeclaration, &streamOutShader));
ANGLE_TRY(allocateResource(context, shaderData, &soDeclaration, &streamOutShader));
}
*outExecutable = new ShaderExecutable11(function, length, std::move(vertexShader),
......@@ -2754,26 +2751,26 @@ angle::Result Renderer11::loadExecutable(d3d::Context *context,
case gl::ShaderType::Fragment:
{
d3d11::PixelShader pixelShader;
ANGLE_TRY(allocateResource(context11, shaderData, &pixelShader));
ANGLE_TRY(allocateResource(context, shaderData, &pixelShader));
*outExecutable = new ShaderExecutable11(function, length, std::move(pixelShader));
}
break;
case gl::ShaderType::Geometry:
{
d3d11::GeometryShader geometryShader;
ANGLE_TRY(allocateResource(context11, shaderData, &geometryShader));
ANGLE_TRY(allocateResource(context, shaderData, &geometryShader));
*outExecutable = new ShaderExecutable11(function, length, std::move(geometryShader));
}
break;
case gl::ShaderType::Compute:
{
d3d11::ComputeShader computeShader;
ANGLE_TRY(allocateResource(context11, shaderData, &computeShader));
ANGLE_TRY(allocateResource(context, shaderData, &computeShader));
*outExecutable = new ShaderExecutable11(function, length, std::move(computeShader));
}
break;
default:
ANGLE_HR_UNREACHABLE(context11);
ANGLE_HR_UNREACHABLE(context);
}
return angle::Result::Continue;
......
......@@ -120,7 +120,7 @@ template <class D3DShaderType>
angle::Result Blit9::setShader(Context9 *context9,
ShaderId source,
const char *profile,
angle::Result (Renderer9::*createShader)(Context9 *,
angle::Result (Renderer9::*createShader)(d3d::Context *,
const DWORD *,
size_t length,
D3DShaderType **outShader),
......
......@@ -28,6 +28,11 @@ class Context9;
class Renderer9;
class TextureStorage;
namespace d3d
{
class Context;
} // namespace d3d
class Blit9 : angle::NonCopyable
{
public:
......@@ -140,7 +145,7 @@ class Blit9 : angle::NonCopyable
angle::Result setShader(Context9 *,
ShaderId source,
const char *profile,
angle::Result (Renderer9::*createShader)(Context9 *context9,
angle::Result (Renderer9::*createShader)(d3d::Context *context,
const DWORD *,
size_t length,
D3DShaderType **outShader),
......
......@@ -850,20 +850,20 @@ void Renderer9::freeEventQuery(IDirect3DQuery9 *query)
}
}
angle::Result Renderer9::createVertexShader(Context9 *context9,
angle::Result Renderer9::createVertexShader(d3d::Context *context,
const DWORD *function,
size_t length,
IDirect3DVertexShader9 **outShader)
{
return mVertexShaderCache.create(context9, function, length, outShader);
return mVertexShaderCache.create(context, function, length, outShader);
}
angle::Result Renderer9::createPixelShader(Context9 *context9,
angle::Result Renderer9::createPixelShader(d3d::Context *context,
const DWORD *function,
size_t length,
IDirect3DPixelShader9 **outShader)
{
return mPixelShaderCache.create(context9, function, length, outShader);
return mPixelShaderCache.create(context, function, length, outShader);
}
HRESULT Renderer9::createVertexBuffer(UINT Length,
......@@ -2586,21 +2586,19 @@ angle::Result Renderer9::loadExecutable(d3d::Context *context,
// Transform feedback is not supported in ES2 or D3D9
ASSERT(streamOutVaryings.empty());
Context9 *context9 = static_cast<Context9 *>(context);
switch (type)
{
case gl::ShaderType::Vertex:
{
IDirect3DVertexShader9 *vshader = nullptr;
ANGLE_TRY(createVertexShader(context9, (DWORD *)function, length, &vshader));
ANGLE_TRY(createVertexShader(context, (DWORD *)function, length, &vshader));
*outExecutable = new ShaderExecutable9(function, length, vshader);
}
break;
case gl::ShaderType::Fragment:
{
IDirect3DPixelShader9 *pshader = nullptr;
ANGLE_TRY(createPixelShader(context9, (DWORD *)function, length, &pshader));
ANGLE_TRY(createPixelShader(context, (DWORD *)function, length, &pshader));
*outExecutable = new ShaderExecutable9(function, length, pshader);
}
break;
......
......@@ -109,11 +109,11 @@ class Renderer9 : public RendererD3D
void freeEventQuery(IDirect3DQuery9 *query);
// resource creation
angle::Result createVertexShader(Context9 *context9,
angle::Result createVertexShader(d3d::Context *context,
const DWORD *function,
size_t length,
IDirect3DVertexShader9 **outShader);
angle::Result createPixelShader(Context9 *context9,
angle::Result createPixelShader(d3d::Context *context,
const DWORD *function,
size_t length,
IDirect3DPixelShader9 **outShader);
......
......@@ -36,7 +36,7 @@ class ShaderCache : angle::NonCopyable
void initialize(IDirect3DDevice9 *device) { mDevice = device; }
angle::Result create(Context9 *context9,
angle::Result create(d3d::Context *context,
const DWORD *function,
size_t length,
ShaderObject **outShaderObject)
......@@ -54,7 +54,7 @@ class ShaderCache : angle::NonCopyable
ShaderObject *shader;
HRESULT result = createShader(function, &shader);
ANGLE_TRY_HR(context9, result, "Failed to create shader");
ANGLE_TRY_HR(context, result, "Failed to create shader");
// Random eviction policy.
if (mMap.size() >= kMaxMapSize)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment