Commit dd4723e3 by Cody Northrop Committed by Commit Bot

Capture/Replay: More ES 3.1 support

This CL adds the following changes: * Support variable block sizes for ASTC * Support glMapBuffer * Additional param captures Test: Capture from beginning of Asphalt 8 and Aztec Ruins Bug: b/150484427 Bug: b/160808198 Change-Id: Ic1041011c3f51c32dbf7bf7105f41dffb9460b87 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2264832 Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarManh Nguyen <nguyenmh@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 7ce16cda
......@@ -469,20 +469,34 @@ void WriteCppReplayForCall(const CallCapture &call,
callOut << "gSyncMap[" << SyncIndexValue(sync) << "] = ";
}
// Depending on how a buffer is mapped, we may need to track its location for readback
bool trackBufferPointer = false;
if (call.entryPoint == gl::EntryPoint::MapBufferRange ||
call.entryPoint == gl::EntryPoint::MapBufferRangeEXT)
{
GLbitfield access =
call.params.getParam("access", ParamType::TGLbitfield, 3).value.GLbitfieldVal;
if (access & GL_MAP_WRITE_BIT)
{
// Track the returned pointer so we update its data when unmapped
gl::BufferID bufferID = call.params.getMappedBufferID();
callOut << "gMappedBufferData[";
WriteParamValueReplay<ParamType::TBufferID>(callOut, call, bufferID);
callOut << "] = ";
}
trackBufferPointer = access & GL_MAP_WRITE_BIT;
}
if (call.entryPoint == gl::EntryPoint::MapBuffer ||
call.entryPoint == gl::EntryPoint::MapBufferOES)
{
GLenum access = call.params.getParam("access", ParamType::TGLenum, 1).value.GLenumVal;
trackBufferPointer =
access == GL_WRITE_ONLY_OES || access == GL_WRITE_ONLY || access == GL_READ_WRITE;
}
if (trackBufferPointer)
{
// Track the returned pointer so we update its data when unmapped
gl::BufferID bufferID = call.params.getMappedBufferID();
callOut << "gMappedBufferData[";
WriteParamValueReplay<ParamType::TBufferID>(callOut, call, bufferID);
callOut << "] = ";
}
callOut << call.name() << "(";
......@@ -2103,9 +2117,10 @@ void CaptureMidExecutionSetup(const gl::Context *context,
frameCapture->getResouceTracker().setStartingBufferMapped(buffer->id(), true);
frameCapture->trackBufferMapping(
&setupCalls->back(), buffer->id(), static_cast<GLsizeiptr>(buffer->getMapOffset()),
static_cast<GLsizeiptr>(buffer->getMapLength()), buffer->getAccessFlags());
frameCapture->trackBufferMapping(&setupCalls->back(), buffer->id(),
static_cast<GLsizeiptr>(buffer->getMapOffset()),
static_cast<GLsizeiptr>(buffer->getMapLength()),
(buffer->getAccessFlags() & GL_MAP_WRITE_BIT) != 0);
}
else
{
......@@ -3485,14 +3500,14 @@ void FrameCapture::captureCompressedTextureData(const gl::Context *context, cons
call.params.getParam("zoffset", ParamType::TGLint, zoffsetParamOffset).value.GLintVal;
}
// Since we're dealing in 4x4 blocks, scale down the width/height pixel offsets.
ASSERT(format.compressedBlockWidth == 4);
ASSERT(format.compressedBlockHeight == 4);
// Scale down the width/height pixel offsets to reflect block size
int widthScale = static_cast<int>(format.compressedBlockWidth);
int heightScale = static_cast<int>(format.compressedBlockHeight);
ASSERT(format.compressedBlockDepth == 1);
pixelWidth >>= 2;
pixelHeight >>= 2;
xoffset >>= 2;
yoffset >>= 2;
pixelWidth /= widthScale;
pixelHeight /= heightScale;
xoffset /= widthScale;
yoffset /= heightScale;
// Update pixel data.
std::vector<uint8_t> &levelData = foundLevel->second;
......@@ -3501,8 +3516,8 @@ void FrameCapture::captureCompressedTextureData(const gl::Context *context, cons
GLint pixelRowPitch = pixelWidth * pixelBytes;
GLint pixelDepthPitch = pixelRowPitch * pixelHeight;
GLint levelRowPitch = (levelExtents.width >> 2) * pixelBytes;
GLint levelDepthPitch = levelRowPitch * (levelExtents.height >> 2);
GLint levelRowPitch = (levelExtents.width / widthScale) * pixelBytes;
GLint levelDepthPitch = levelRowPitch * (levelExtents.height / heightScale);
for (GLint zindex = 0; zindex < pixelDepth; ++zindex)
{
......@@ -3528,12 +3543,12 @@ void FrameCapture::trackBufferMapping(CallCapture *call,
gl::BufferID id,
GLintptr offset,
GLsizeiptr length,
GLbitfield accessFlags)
bool writable)
{
// Track that the buffer was mapped
mResourceTracker.setBufferMapped(id);
if (accessFlags & GL_MAP_WRITE_BIT)
if (writable)
{
// If this buffer was mapped writable, we don't have any visibility into what
// happens to it. Therefore, remember the details about it, and we'll read it back
......@@ -3725,15 +3740,27 @@ void FrameCapture::maybeCaptureClientData(const gl::Context *context, CallCaptur
}
case gl::EntryPoint::MapBuffer:
{
UNIMPLEMENTED();
break;
}
case gl::EntryPoint::MapBufferOES:
{
UNIMPLEMENTED();
gl::BufferBinding target =
call.params.getParam("targetPacked", ParamType::TBufferBinding, 0)
.value.BufferBindingVal;
GLbitfield access =
call.params.getParam("access", ParamType::TGLenum, 1).value.GLenumVal;
gl::Buffer *buffer = context->getState().getTargetBuffer(target);
GLintptr offset = 0;
GLsizeiptr length = static_cast<GLsizeiptr>(buffer->getSize());
bool writable =
access == GL_WRITE_ONLY_OES || access == GL_WRITE_ONLY || access == GL_READ_WRITE;
trackBufferMapping(&call, buffer->id(), offset, length, writable);
break;
}
case gl::EntryPoint::UnmapNamedBuffer:
{
UNIMPLEMENTED();
......@@ -3755,7 +3782,7 @@ void FrameCapture::maybeCaptureClientData(const gl::Context *context, CallCaptur
.value.BufferBindingVal;
gl::Buffer *buffer = context->getState().getTargetBuffer(target);
trackBufferMapping(&call, buffer->id(), offset, length, access);
trackBufferMapping(&call, buffer->id(), offset, length, access & GL_MAP_WRITE_BIT);
break;
}
......
......@@ -284,7 +284,7 @@ class FrameCapture final : angle::NonCopyable
gl::BufferID id,
GLintptr offset,
GLsizeiptr length,
GLbitfield accessFlags);
bool writable);
ResourceTracker &getResouceTracker() { return mResourceTracker; }
......@@ -389,6 +389,14 @@ void CaptureGetParameter(const gl::State &glState,
size_t typeSize,
ParamCapture *paramCapture);
template <typename T>
void CaptureClearBufferValue(GLenum buffer, const T *value, ParamCapture *paramCapture)
{
// Per the spec, color buffers have a vec4, the rest a single value
uint32_t valueSize = (buffer == GL_COLOR) ? 4 : 1;
CaptureMemory(value, valueSize * sizeof(T), paramCapture);
}
void CaptureGenHandlesImpl(GLsizei n, GLuint *handles, ParamCapture *paramCapture);
template <typename T>
......
......@@ -198,7 +198,7 @@ void CaptureGetActiveAttrib_length(const State &glState,
GLchar *name,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
paramCapture->readBufferSizeBytes = sizeof(GLsizei);
}
void CaptureGetActiveAttrib_size(const State &glState,
......@@ -212,7 +212,7 @@ void CaptureGetActiveAttrib_size(const State &glState,
GLchar *name,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
paramCapture->readBufferSizeBytes = sizeof(GLint);
}
void CaptureGetActiveAttrib_type(const State &glState,
......@@ -226,7 +226,7 @@ void CaptureGetActiveAttrib_type(const State &glState,
GLchar *name,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
paramCapture->readBufferSizeBytes = sizeof(GLenum);
}
void CaptureGetActiveAttrib_name(const State &glState,
......
......@@ -20,7 +20,7 @@ void CaptureClearBufferfv_value(const State &glState,
const GLfloat *value,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
CaptureClearBufferValue<GLfloat>(buffer, value, paramCapture);
}
void CaptureClearBufferiv_value(const State &glState,
......@@ -30,7 +30,7 @@ void CaptureClearBufferiv_value(const State &glState,
const GLint *value,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
CaptureClearBufferValue<GLint>(buffer, value, paramCapture);
}
void CaptureClearBufferuiv_value(const State &glState,
......@@ -40,7 +40,7 @@ void CaptureClearBufferuiv_value(const State &glState,
const GLuint *value,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
CaptureClearBufferValue<GLuint>(buffer, value, paramCapture);
}
void CaptureCompressedTexImage3D_data(const State &glState,
......@@ -291,7 +291,7 @@ void CaptureGetInteger64i_v_data(const State &glState,
GLint64 *data,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
CaptureGetParameter(glState, target, sizeof(GLint64), paramCapture);
}
void CaptureGetInteger64v_data(const State &glState,
......@@ -300,7 +300,7 @@ void CaptureGetInteger64v_data(const State &glState,
GLint64 *data,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
CaptureGetParameter(glState, pname, sizeof(GLint64), paramCapture);
}
void CaptureGetIntegeri_v_data(const State &glState,
......@@ -310,7 +310,7 @@ void CaptureGetIntegeri_v_data(const State &glState,
GLint *data,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
CaptureGetParameter(glState, target, sizeof(GLint), paramCapture);
}
void CaptureGetInternalformativ_params(const State &glState,
......
......@@ -171,7 +171,7 @@ void CaptureGetProgramResourceName_length(const State &glState,
GLchar *name,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
paramCapture->readBufferSizeBytes = sizeof(GLsizei);
}
void CaptureGetProgramResourceName_name(const State &glState,
......@@ -184,7 +184,7 @@ void CaptureGetProgramResourceName_name(const State &glState,
GLchar *name,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
CaptureString(name, paramCapture);
}
void CaptureGetProgramResourceiv_props(const State &glState,
......@@ -199,7 +199,7 @@ void CaptureGetProgramResourceiv_props(const State &glState,
GLint *params,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
CaptureMemory(props, sizeof(GLenum) * propCount, paramCapture);
}
void CaptureGetProgramResourceiv_length(const State &glState,
......@@ -214,7 +214,7 @@ void CaptureGetProgramResourceiv_length(const State &glState,
GLint *params,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
paramCapture->readBufferSizeBytes = sizeof(GLsizei);
}
void CaptureGetProgramResourceiv_params(const State &glState,
......@@ -229,7 +229,18 @@ void CaptureGetProgramResourceiv_params(const State &glState,
GLint *params,
ParamCapture *paramCapture)
{
UNIMPLEMENTED();
// See QueryProgramResourceiv for details on how these are handled
for (int i = 0; i < propCount; ++i)
{
if (props[i] == GL_ACTIVE_VARIABLES)
{
// This appears to be the only property that isn't a single integer
UNIMPLEMENTED();
return;
}
}
CaptureMemory(props, sizeof(GLint) * propCount, paramCapture);
}
void CaptureGetTexLevelParameterfv_params(const State &glState,
......
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