Commit 0e65abea by Geoff Lang Committed by Commit Bot

D3D11: Serialize and deserialze mImage2DUniforms.

mImage2DUniforms was not saved with the program binary causing shaders with images to fail compilation when loaded from binary. BUG: angleproject:4519 BUG: b:152292873 Change-Id: I51581031ae1f9d4b4d986057ef3f876d809c7f24 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2124587Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Commit-Queue: Courtney Goeltzenleuchter <courtneygo@google.com>
parent 7e0699a2
......@@ -650,35 +650,6 @@ bool ValidateInterfaceBlocksMatch(
return true;
}
void WriteShaderVar(BinaryOutputStream *stream, const sh::ShaderVariable &var)
{
stream->writeInt(var.type);
stream->writeInt(var.precision);
stream->writeString(var.name);
stream->writeString(var.mappedName);
stream->writeIntVector(var.arraySizes);
stream->writeInt(var.staticUse);
stream->writeInt(var.active);
stream->writeInt(var.binding);
stream->writeString(var.structName);
stream->writeInt(var.hasParentArrayIndex() ? var.parentArrayIndex() : -1);
ASSERT(var.fields.empty());
}
void LoadShaderVar(BinaryInputStream *stream, sh::ShaderVariable *var)
{
var->type = stream->readInt<GLenum>();
var->precision = stream->readInt<GLenum>();
var->name = stream->readString();
var->mappedName = stream->readString();
stream->readIntVector<unsigned int>(&var->arraySizes);
var->staticUse = stream->readBool();
var->active = stream->readBool();
var->binding = stream->readInt<int>();
var->structName = stream->readString();
var->setParentArrayIndex(stream->readInt<int>());
}
void WriteShaderVariableBuffer(BinaryOutputStream *stream, const ShaderVariableBuffer &var)
{
stream->writeInt(var.binding);
......@@ -912,6 +883,46 @@ void LoadBlockMemberInfo(BinaryInputStream *stream, sh::BlockMemberInfo *var)
var->topLevelArrayStride = stream->readInt<int>();
}
void WriteShaderVar(BinaryOutputStream *stream, const sh::ShaderVariable &var)
{
stream->writeInt(var.type);
stream->writeInt(var.precision);
stream->writeString(var.name);
stream->writeString(var.mappedName);
stream->writeIntVector(var.arraySizes);
stream->writeInt(var.staticUse);
stream->writeInt(var.active);
stream->writeInt(var.binding);
stream->writeString(var.structName);
stream->writeInt(var.hasParentArrayIndex() ? var.parentArrayIndex() : -1);
stream->writeInt(var.imageUnitFormat);
stream->writeInt(var.offset);
stream->writeInt(var.readonly);
stream->writeInt(var.writeonly);
ASSERT(var.fields.empty());
}
void LoadShaderVar(BinaryInputStream *stream, sh::ShaderVariable *var)
{
var->type = stream->readInt<GLenum>();
var->precision = stream->readInt<GLenum>();
var->name = stream->readString();
var->mappedName = stream->readString();
stream->readIntVector<unsigned int>(&var->arraySizes);
var->staticUse = stream->readBool();
var->active = stream->readBool();
var->binding = stream->readInt<int>();
var->structName = stream->readString();
var->setParentArrayIndex(stream->readInt<int>());
var->imageUnitFormat = stream->readInt<GLenum>();
var->offset = stream->readInt<int>();
var->readonly = stream->readBool();
var->writeonly = stream->readBool();
}
// VariableLocation implementation.
VariableLocation::VariableLocation() : arrayIndex(0), index(kUnused), ignored(false) {}
......
......@@ -98,6 +98,9 @@ bool IsActiveInterfaceBlock(const sh::InterfaceBlock &interfaceBlock);
void WriteBlockMemberInfo(BinaryOutputStream *stream, const sh::BlockMemberInfo &var);
void LoadBlockMemberInfo(BinaryInputStream *stream, sh::BlockMemberInfo *var);
void WriteShaderVar(BinaryOutputStream *stream, const sh::ShaderVariable &var);
void LoadShaderVar(BinaryInputStream *stream, sh::ShaderVariable *var);
// Struct used for correlating uniforms/elements of uniform arrays to handles
struct VariableLocation
{
......
......@@ -1047,6 +1047,22 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context,
mD3DShaderStorageBlocks.push_back(shaderStorageBlock);
}
const unsigned int image2DUniformCount = stream->readInt<unsigned int>();
if (stream->error())
{
infoLog << "Invalid program binary.";
return std::make_unique<LinkEventDone>(angle::Result::Incomplete);
}
ASSERT(mImage2DUniforms.empty());
for (unsigned int image2DUniformIndex = 0; image2DUniformIndex < image2DUniformCount;
++image2DUniformIndex)
{
sh::ShaderVariable image2Duniform;
gl::LoadShaderVar(stream, &image2Duniform);
mImage2DUniforms.push_back(image2Duniform);
}
for (unsigned int ii = 0; ii < gl::IMPLEMENTATION_MAX_ATOMIC_COUNTER_BUFFERS; ++ii)
{
unsigned int index = stream->readInt<unsigned int>();
......@@ -1358,6 +1374,12 @@ void ProgramD3D::save(const gl::Context *context, gl::BinaryOutputStream *stream
}
}
stream->writeInt(mImage2DUniforms.size());
for (const sh::ShaderVariable &image2DUniform : mImage2DUniforms)
{
gl::WriteShaderVar(stream, image2DUniform);
}
for (unsigned int ii = 0; ii < gl::IMPLEMENTATION_MAX_ATOMIC_COUNTER_BUFFERS; ++ii)
{
stream->writeInt(mComputeAtomicCounterBufferRegisterIndices[ii]);
......
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