瀏覽代碼

ASV changes for ATOM-15939 Add support to capture attachment for Pare… (#162)

* ASV changes for ATOM-15939 Add support to capture attachment for ParentPass

Signed-off-by: Tao <[email protected]>

* Update readback option to enum

Signed-off-by: Tao <[email protected]>
Qing Tao 4 年之前
父節點
當前提交
90e6f3bac3
共有 2 個文件被更改,包括 23 次插入5 次删除
  1. 21 4
      Gem/Code/Source/Automation/ScriptManager.cpp
  2. 2 1
      Gem/Code/Source/TonemappingExampleComponent.cpp

+ 21 - 4
Gem/Code/Source/Automation/ScriptManager.cpp

@@ -1163,9 +1163,9 @@ namespace AtomSampleViewer
 
     void ScriptManager::Script_CapturePassAttachment(AZ::ScriptDataContext& dc)
     {
-        if (dc.GetNumArguments() != 3)
+        if (dc.GetNumArguments() != 3 && dc.GetNumArguments() != 4)
         {
-            ReportScriptError("CapturePassAttachment needs three arguments");
+            ReportScriptError("CapturePassAttachment needs three or four arguments");
             return;
         }
 
@@ -1181,6 +1181,12 @@ namespace AtomSampleViewer
             return;
         }
 
+        if (dc.GetNumArguments() == 4 && !dc.IsString(3))
+        {
+            ReportScriptError("CapturePassAttachment's forth argument must be a string 'Input' or 'Output'");
+            return;
+        }
+
         const char* stringValue = nullptr;
 
         AZStd::vector<AZStd::string> passHierarchy;
@@ -1193,6 +1199,17 @@ namespace AtomSampleViewer
         dc.ReadArg(2, stringValue);
         outputFilePath = AZStd::string(stringValue);
 
+        AZ::RPI::PassAttachmentReadbackOption readbackOption = AZ::RPI::PassAttachmentReadbackOption::Output;
+        if (dc.GetNumArguments() == 4)
+        {
+            AZStd::string option;
+            dc.ReadArg(3, option);
+            if (option == "Input")
+            {
+                readbackOption = AZ::RPI::PassAttachmentReadbackOption::Input;
+            }
+        }
+
         // read pass hierarchy
         AZ::ScriptDataContext stringtable;
         dc.InspectTable(0, stringtable);
@@ -1219,12 +1236,12 @@ namespace AtomSampleViewer
             }
         }
 
-        auto operation = [passHierarchy, slot, outputFilePath]()
+        auto operation = [passHierarchy, slot, outputFilePath, readbackOption]()
         {
             // Note this will pause the script until the capture is complete
             if (PrepareForScreenCapture(outputFilePath))
             {
-                AZ::Render::FrameCaptureRequestBus::Broadcast(&AZ::Render::FrameCaptureRequestBus::Events::CapturePassAttachment, passHierarchy, slot, outputFilePath);
+                AZ::Render::FrameCaptureRequestBus::Broadcast(&AZ::Render::FrameCaptureRequestBus::Events::CapturePassAttachment, passHierarchy, slot, outputFilePath, readbackOption);
             }
         };
 

+ 2 - 1
Gem/Code/Source/TonemappingExampleComponent.cpp

@@ -315,7 +315,8 @@ namespace AtomSampleViewer
     {
         AZStd::string filePath = m_imguiFrameCaptureSaver.GetSaveFilePath();
         AZStd::string slot = "Output";
-        AZ::Render::FrameCaptureRequestBus::Broadcast(&AZ::Render::FrameCaptureRequestBus::Events::CapturePassAttachment, m_capturePassHierarchy, slot, filePath);
+        AZ::Render::FrameCaptureRequestBus::Broadcast(&AZ::Render::FrameCaptureRequestBus::Events::CapturePassAttachment, m_capturePassHierarchy, slot, filePath,
+            AZ::RPI::PassAttachmentReadbackOption::Output);
     }
 
     RPI::ColorSpaceId TonemappingExampleComponent::GetColorSpaceIdForIndex(uint8_t colorSpaceIndex) const