Commit 57c6af7d by Jamie Madill Committed by Commit Bot

Capture/Replay: Fix temp shader ID.

We could mess up capturing Program #1 by using a temp shader ID of 1. Instead we can use a shader ID that isn't used in the application. Noticed when capturing from the T-Rex replay. Bug: angleproject:5134 Change-Id: Ic6fefe9d8cdf327a5ebbb47539b2e11161a4b13c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2449159 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com>
parent 9f5eb0b8
...@@ -2799,8 +2799,8 @@ void CaptureMidExecutionSetup(const gl::Context *context, ...@@ -2799,8 +2799,8 @@ void CaptureMidExecutionSetup(const gl::Context *context,
const gl::ResourceMap<gl::Program, gl::ShaderProgramID> &programs = const gl::ResourceMap<gl::Program, gl::ShaderProgramID> &programs =
shadersAndPrograms.getProgramsForCapture(); shadersAndPrograms.getProgramsForCapture();
// Capture Program binary state. Use shader ID 1 as a temporary shader ID. // Capture Program binary state. Use max ID as a temporary shader ID.
gl::ShaderProgramID tempShaderID = {1}; gl::ShaderProgramID tempShaderID = {resourceTracker->getMaxShaderPrograms()};
for (const auto &programIter : programs) for (const auto &programIter : programs)
{ {
gl::ShaderProgramID id = {programIter.first}; gl::ShaderProgramID id = {programIter.first};
...@@ -2874,6 +2874,8 @@ void CaptureMidExecutionSetup(const gl::Context *context, ...@@ -2874,6 +2874,8 @@ void CaptureMidExecutionSetup(const gl::Context *context,
cap(CaptureLinkProgram(replayState, true, id)); cap(CaptureLinkProgram(replayState, true, id));
CaptureUpdateUniformLocations(program, setupCalls); CaptureUpdateUniformLocations(program, setupCalls);
CaptureUpdateUniformValues(replayState, context, program, setupCalls); CaptureUpdateUniformValues(replayState, context, program, setupCalls);
resourceTracker->onShaderProgramAccess(id);
} }
// Handle shaders. // Handle shaders.
...@@ -3382,6 +3384,20 @@ bool SkipCall(gl::EntryPoint entryPoint) ...@@ -3382,6 +3384,20 @@ bool SkipCall(gl::EntryPoint entryPoint)
return false; return false;
} }
bool FindShaderProgramIDInCall(const CallCapture &call, gl::ShaderProgramID *idOut)
{
for (const ParamCapture &param : call.params.getParamCaptures())
{
if (param.type == ParamType::TShaderProgramID && param.name == "programPacked")
{
*idOut = param.value.ShaderProgramIDVal;
return true;
}
}
return false;
}
} // namespace } // namespace
ParamCapture::ParamCapture() : type(ParamType::TGLenum), enumGroup(gl::GLenumGroup::DefaultGroup) {} ParamCapture::ParamCapture() : type(ParamType::TGLenum), enumGroup(gl::GLenumGroup::DefaultGroup) {}
...@@ -3874,7 +3890,7 @@ void FrameCapture::maybeOverrideEntryPoint(const gl::Context *context, CallCaptu ...@@ -3874,7 +3890,7 @@ void FrameCapture::maybeOverrideEntryPoint(const gl::Context *context, CallCaptu
} }
} }
void FrameCapture::maybeCaptureClientData(const gl::Context *context, CallCapture &call) void FrameCapture::maybeCapturePreCallUpdates(const gl::Context *context, CallCapture &call)
{ {
switch (call.entryPoint) switch (call.entryPoint)
{ {
...@@ -4138,6 +4154,14 @@ void FrameCapture::maybeCaptureClientData(const gl::Context *context, CallCaptur ...@@ -4138,6 +4154,14 @@ void FrameCapture::maybeCaptureClientData(const gl::Context *context, CallCaptur
default: default:
break; break;
} }
mReadBufferSize = std::max(mReadBufferSize, call.params.getReadBufferSize());
gl::ShaderProgramID shaderProgramID;
if (FindShaderProgramIDInCall(call, &shaderProgramID))
{
mResourceTracker.onShaderProgramAccess(shaderProgramID);
}
} }
void FrameCapture::captureCall(const gl::Context *context, CallCapture &&call) void FrameCapture::captureCall(const gl::Context *context, CallCapture &&call)
...@@ -4147,10 +4171,8 @@ void FrameCapture::captureCall(const gl::Context *context, CallCapture &&call) ...@@ -4147,10 +4171,8 @@ void FrameCapture::captureCall(const gl::Context *context, CallCapture &&call)
maybeOverrideEntryPoint(context, call); maybeOverrideEntryPoint(context, call);
// Process client data snapshots. maybeCapturePreCallUpdates(context, call);
maybeCaptureClientData(context, call);
mReadBufferSize = std::max(mReadBufferSize, call.params.getReadBufferSize());
mFrameCalls.emplace_back(std::move(call)); mFrameCalls.emplace_back(std::move(call));
maybeCapturePostCallUpdates(context); maybeCapturePostCallUpdates(context);
...@@ -4522,6 +4544,11 @@ void ResourceTracker::setBufferUnmapped(gl::BufferID id) ...@@ -4522,6 +4544,11 @@ void ResourceTracker::setBufferUnmapped(gl::BufferID id)
} }
} }
void ResourceTracker::onShaderProgramAccess(gl::ShaderProgramID shaderProgramID)
{
mMaxShaderPrograms = std::max(mMaxShaderPrograms, shaderProgramID.value + 1);
}
bool FrameCapture::isCapturing() const bool FrameCapture::isCapturing() const
{ {
// Currently we will always do a capture up until the last frame. In the future we could improve // Currently we will always do a capture up until the last frame. In the future we could improve
...@@ -4816,20 +4843,6 @@ void WriteParamValueReplay<ParamType::TVertexArrayID>(std::ostream &os, ...@@ -4816,20 +4843,6 @@ void WriteParamValueReplay<ParamType::TVertexArrayID>(std::ostream &os,
os << "gVertexArrayMap[" << value.value << "]"; os << "gVertexArrayMap[" << value.value << "]";
} }
bool FindShaderProgramIDInCall(const CallCapture &call, gl::ShaderProgramID *idOut)
{
for (const ParamCapture &param : call.params.getParamCaptures())
{
if (param.type == ParamType::TShaderProgramID && param.name == "programPacked")
{
*idOut = param.value.ShaderProgramIDVal;
return true;
}
}
return false;
}
template <> template <>
void WriteParamValueReplay<ParamType::TUniformLocation>(std::ostream &os, void WriteParamValueReplay<ParamType::TUniformLocation>(std::ostream &os,
const CallCapture &call, const CallCapture &call,
......
...@@ -253,6 +253,9 @@ class ResourceTracker final : angle::NonCopyable ...@@ -253,6 +253,9 @@ class ResourceTracker final : angle::NonCopyable
mStartingBuffersMappedInitial[id] = mapped; mStartingBuffersMappedInitial[id] = mapped;
} }
void onShaderProgramAccess(gl::ShaderProgramID shaderProgramID);
uint32_t getMaxShaderPrograms() const { return mMaxShaderPrograms; }
private: private:
// Buffer regen calls will delete and gen a buffer // Buffer regen calls will delete and gen a buffer
BufferCalls mBufferRegenCalls; BufferCalls mBufferRegenCalls;
...@@ -276,6 +279,9 @@ class ResourceTracker final : angle::NonCopyable ...@@ -276,6 +279,9 @@ class ResourceTracker final : angle::NonCopyable
BufferMapStatusMap mStartingBuffersMappedInitial; BufferMapStatusMap mStartingBuffersMappedInitial;
// The status of buffer mapping throughout the trace, modified with each Map/Unmap call // The status of buffer mapping throughout the trace, modified with each Map/Unmap call
BufferMapStatusMap mStartingBuffersMappedCurrent; BufferMapStatusMap mStartingBuffersMappedCurrent;
// Maximum accessed shader program ID.
uint32_t mMaxShaderPrograms = 0;
}; };
// Used by the CPP replay to filter out unnecessary code. // Used by the CPP replay to filter out unnecessary code.
...@@ -329,7 +335,7 @@ class FrameCapture final : angle::NonCopyable ...@@ -329,7 +335,7 @@ class FrameCapture final : angle::NonCopyable
void reset(); void reset();
void maybeOverrideEntryPoint(const gl::Context *context, CallCapture &call); void maybeOverrideEntryPoint(const gl::Context *context, CallCapture &call);
void maybeCaptureClientData(const gl::Context *context, CallCapture &call); void maybeCapturePreCallUpdates(const gl::Context *context, CallCapture &call);
void maybeCapturePostCallUpdates(const gl::Context *context); void maybeCapturePostCallUpdates(const gl::Context *context);
static void ReplayCall(gl::Context *context, static void ReplayCall(gl::Context *context,
......
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