From 1d555687bc7d8feb8161ec1e916d3084bfa7cbf2 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Tue, 9 Nov 2021 11:16:24 +0100 Subject: [PATCH] Capture/Replay: Set FBO ID when generated on bind GLES allows FBO ID's to be reserved on bind, so if a FBO is bound with and ID that was not yet reserved by a glGenFramebuffers call, update the resource tracking and the resource map to account for this resources that was created on bind. Bug: angleproject:6425 Change-Id: I343fc17bfbbfd9c8c47d6fe207a4f3817acb835d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3190970 Commit-Queue: Gert Wollny Reviewed-by: Jamie Madill Reviewed-by: Cody Northrop --- src/libANGLE/capture/FrameCapture.cpp | 39 +++++++++++++++++++ src/libANGLE/capture/FrameCapture.h | 11 ++++++ src/libANGLE/capture/trace_fixture.cpp | 15 +++++++ src/libANGLE/capture/trace_fixture.h | 2 + .../capture_replay_expectations.txt | 4 -- 5 files changed, 67 insertions(+), 4 deletions(-) diff --git a/src/libANGLE/capture/FrameCapture.cpp b/src/libANGLE/capture/FrameCapture.cpp index 12e727251..280b0deb0 100644 --- a/src/libANGLE/capture/FrameCapture.cpp +++ b/src/libANGLE/capture/FrameCapture.cpp @@ -4985,6 +4985,7 @@ void FrameCaptureShared::maybeCapturePreCallUpdates( } case EntryPoint::GLGenFramebuffers: + case EntryPoint::GLGenFramebuffersOES: { GLsizei count = call.params.getParam("n", ParamType::TGLsizei, 0).value.GLsizeiVal; const gl::FramebufferID *framebufferIDs = @@ -4996,6 +4997,13 @@ void FrameCaptureShared::maybeCapturePreCallUpdates( } break; } + + case EntryPoint::GLBindFramebuffer: + case EntryPoint::GLBindFramebufferOES: + maybeGenResourceOnBind(call, "framebufferPacked", + ParamType::TFramebufferID); + break; + case EntryPoint::GLGenTextures: { GLsizei count = call.params.getParam("n", ParamType::TGLsizei, 0).value.GLsizeiVal; @@ -5359,6 +5367,32 @@ void FrameCaptureShared::maybeCapturePreCallUpdates( updateResourceCounts(call); } +template +void FrameCaptureShared::maybeGenResourceOnBind(CallCapture &call, + const char *paramName, + ParamType paramType) +{ + const ParamCapture ¶m = call.params.getParam(paramName, paramType, 1); + const ParamValueType id = AccessParamValue(paramType, param.value); + + // Don't inject the default resource or resources that are already generated + if (id.value != 0 && !resourceIsGenerated(id)) + { + handleGennedResource(id); + + ResourceIDType resourceIDType = GetResourceIDTypeFromParamType(param.type); + const char *resourceName = GetResourceIDTypeName(resourceIDType); + + std::stringstream updateFuncNameStr; + updateFuncNameStr << "Set" << resourceName << "ID"; + std::string updateFuncName = updateFuncNameStr.str(); + + ParamBuffer params; + params.addValueParam("id", ParamType::TGLuint, id.value); + mFrameCalls.emplace_back(updateFuncName, std::move(params)); + } +} + void FrameCaptureShared::updateResourceCounts(const CallCapture &call) { for (const ParamCapture ¶m : call.params.getParamCaptures()) @@ -5927,6 +5961,11 @@ void TrackedResource::setGennedResource(GLuint id) } } +bool TrackedResource::resourceIsGenerated(GLuint id) +{ + return mNewResources.find(id) != mNewResources.end(); +} + void TrackedResource::setDeletedResource(GLuint id) { if (id == 0) diff --git a/src/libANGLE/capture/FrameCapture.h b/src/libANGLE/capture/FrameCapture.h index 399397bf3..5aefb06eb 100644 --- a/src/libANGLE/capture/FrameCapture.h +++ b/src/libANGLE/capture/FrameCapture.h @@ -236,6 +236,7 @@ class TrackedResource final : angle::NonCopyable void setGennedResource(GLuint id); void setDeletedResource(GLuint id); void setModifiedResource(GLuint id); + bool resourceIsGenerated(GLuint id); ResourceCalls &getResourceRegenCalls() { return mResourceRegenCalls; } ResourceCalls &getResourceRestoreCalls() { return mResourceRestoreCalls; } @@ -486,6 +487,14 @@ class FrameCaptureShared final : angle::NonCopyable } } + template + bool resourceIsGenerated(ResourceType resourceID) + { + ResourceIDType idType = GetResourceIDTypeFromType::IDType; + TrackedResource &tracker = mResourceTracker.getTrackedResource(idType); + return tracker.resourceIsGenerated(resourceID.value); + } + template void handleDeletedResource(ResourceType resourceID) { @@ -518,6 +527,8 @@ class FrameCaptureShared final : angle::NonCopyable CallCapture &call, std::vector *shareGroupSetupCalls, ResourceIDToSetupCallsMap *resourceIDToSetupCalls); + template + void maybeGenResourceOnBind(CallCapture &call, const char *paramName, ParamType paramType); void maybeCapturePostCallUpdates(const gl::Context *context); void maybeCaptureDrawArraysClientData(const gl::Context *context, CallCapture &call, diff --git a/src/libANGLE/capture/trace_fixture.cpp b/src/libANGLE/capture/trace_fixture.cpp index 303d35794..8e24ff72b 100644 --- a/src/libANGLE/capture/trace_fixture.cpp +++ b/src/libANGLE/capture/trace_fixture.cpp @@ -406,6 +406,21 @@ void UpdateVertexArrayID2(GLuint id, GLsizei readBufferOffset) UpdateResourceMap2(gVertexArrayMap2, id, readBufferOffset); } +void SetResourceID(GLuint *map, GLuint id) +{ + if (map[id] != 0) + { + fprintf(stderr, "%s: resource ID %d is already reserved\n", __func__, id); + exit(1); + } + map[id] = id; +} + +void SetFramebufferID(GLuint id) +{ + SetResourceID(gFramebufferMap2, id); +} + void ValidateSerializedState(const char *serializedState, const char *fileName, uint32_t line) { if (gValidateSerializedStateCallback) diff --git a/src/libANGLE/capture/trace_fixture.h b/src/libANGLE/capture/trace_fixture.h index edb84f682..ef20b238c 100644 --- a/src/libANGLE/capture/trace_fixture.h +++ b/src/libANGLE/capture/trace_fixture.h @@ -176,6 +176,8 @@ void UpdateTextureID2(GLuint id, GLsizei readBufferOffset); void UpdateTransformFeedbackID2(GLuint id, GLsizei readBufferOffset); void UpdateVertexArrayID2(GLuint id, GLsizei readBufferOffset); +void SetFramebufferID(GLuint id); + void ValidateSerializedState(const char *serializedState, const char *fileName, uint32_t line); #define VALIDATE_CHECKPOINT(STATE) ValidateSerializedState(STATE, __FILE__, __LINE__) diff --git a/src/tests/capture_replay_tests/capture_replay_expectations.txt b/src/tests/capture_replay_tests/capture_replay_expectations.txt index afce989ee..e1d593d4c 100644 --- a/src/tests/capture_replay_tests/capture_replay_expectations.txt +++ b/src/tests/capture_replay_tests/capture_replay_expectations.txt @@ -119,10 +119,6 @@ 6286 : ImageTestES3.Source2DTarget2DTargetTextureRespecifyLevel/ES3_Vulkan_SwiftShader = FAIL 6286 : ImageTestES3.Source2DTargetExternalESSL3/ES3_Vulkan_SwiftShader = FAIL 6286 : ImageTestES3.SourceRenderbufferTargetTextureExternalESSL3/ES3_Vulkan_SwiftShader = FAIL -6425 : ObjectAllocationTest.BindFramebufferAfterGen/ES3_Vulkan_SwiftShader = FAIL -6425 : ObjectAllocationTest.BindFramebufferBeforeGen/ES3_Vulkan_SwiftShader = FAIL -6425 : ObjectAllocationTestES3.BindFramebufferAfterGen/ES3_Vulkan_SwiftShader = FAIL -6425 : ObjectAllocationTestES3.BindFramebufferBeforeGen/ES3_Vulkan_SwiftShader = FAIL 6512 : RobustResourceInitTestES3.BindTexImage/ES3_Vulkan_SwiftShader = FAIL 6180 WIN : TransformFeedbackTest.DrawWithoutTransformFeedbackThenWith/ES3_Vulkan_SwiftShader = FLAKY 6513 : TransformFeedbackTest.MultiContext/ES3_Vulkan_SwiftShader = FLAKY