Skip to content

Commit

Permalink
Add support for copying ahb without cpu read mask
Browse files Browse the repository at this point in the history
  • Loading branch information
ziga-lunarg committed Oct 15, 2024
1 parent e7b8da9 commit 1763e52
Show file tree
Hide file tree
Showing 21 changed files with 1,322 additions and 91 deletions.
2 changes: 2 additions & 0 deletions framework/decode/api_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ class ApiDecoder

virtual void
DispatchCreateHardwareBufferCommand(format::ThreadId thread_id,
format::HandleId device_id,
format::HandleId queue_id,
format::HandleId memory_id,
uint64_t buffer_id,
uint32_t format,
Expand Down
2 changes: 2 additions & 0 deletions framework/decode/custom_ags_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class AgsDecoder : public ApiDecoder

virtual void
DispatchCreateHardwareBufferCommand(format::ThreadId thread_id,
format::HandleId device_id,
format::HandleId queue_id,
format::HandleId memory_id,
uint64_t buffer_id,
uint32_t format,
Expand Down
4 changes: 3 additions & 1 deletion framework/decode/dx12_decoder_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ void Dx12DecoderBase::DispatchResizeWindowCommand2(

void Dx12DecoderBase::DispatchCreateHardwareBufferCommand(
format::ThreadId thread_id,
format::HandleId device_id,
format::HandleId queue_id,
format::HandleId memory_id,
uint64_t buffer_id,
uint32_t format,
Expand All @@ -124,7 +126,7 @@ void Dx12DecoderBase::DispatchCreateHardwareBufferCommand(
for (auto consumer : consumers_)
{
consumer->ProcessCreateHardwareBufferCommand(
memory_id, buffer_id, format, width, height, stride, usage, layers, plane_info);
device_id, queue_id, memory_id, buffer_id, format, width, height, stride, usage, layers, plane_info);
}
}

Expand Down
2 changes: 2 additions & 0 deletions framework/decode/dx12_decoder_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ class Dx12DecoderBase : public ApiDecoder

virtual void
DispatchCreateHardwareBufferCommand(format::ThreadId thread_id,
format::HandleId device_id,
format::HandleId queue_id,
format::HandleId memory_id,
uint64_t buffer_id,
uint32_t format,
Expand Down
79 changes: 79 additions & 0 deletions framework/decode/file_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,81 @@ bool FileProcessor::ProcessMetaData(const format::BlockHeader& block_header, for
if (decoder->SupportsMetaDataId(meta_data_id))
{
decoder->DispatchCreateHardwareBufferCommand(header.thread_id,
0u,
0u,
header.memory_id,
header.buffer_id,
header.format,
header.width,
header.height,
header.stride,
header.usage,
header.layers,
entries);
}
}
}
else
{
if (format::IsBlockCompressed(block_header.type))
{
HandleBlockReadError(kErrorReadingCompressedBlockData,
"Failed to read create hardware buffer meta-data block");
}
else
{
HandleBlockReadError(kErrorReadingBlockData,
"Failed to read create hardware buffer meta-data block");
}
}
}
else
{
HandleBlockReadError(kErrorReadingBlockHeader,
"Failed to read create hardware buffer meta-data block header");
}
}
else if (meta_data_type == format::MetaDataType::kCreateHardwareBufferCommand_deprecated2)
{
format::CreateHardwareBufferCommandHeader_deprecated2 header;

success = ReadBytes(&header.thread_id, sizeof(header.thread_id));
success = success && ReadBytes(&header.memory_id, sizeof(header.memory_id));
success = success && ReadBytes(&header.buffer_id, sizeof(header.buffer_id));
success = success && ReadBytes(&header.format, sizeof(header.format));
success = success && ReadBytes(&header.width, sizeof(header.width));
success = success && ReadBytes(&header.height, sizeof(header.height));
success = success && ReadBytes(&header.stride, sizeof(header.stride));
success = success && ReadBytes(&header.usage, sizeof(header.usage));
success = success && ReadBytes(&header.layers, sizeof(header.layers));
success = success && ReadBytes(&header.planes, sizeof(header.planes));

if (success)
{
std::vector<format::HardwareBufferPlaneInfo> entries;

for (uint64_t i = 0; i < header.planes; ++i)
{
format::HardwareBufferPlaneInfo entry;

if (!ReadBytes(&entry, sizeof(entry)))
{
success = false;
break;
}

entries.emplace_back(std::move(entry));
}

if (success)
{
for (auto decoder : decoders_)
{
if (decoder->SupportsMetaDataId(meta_data_id))
{
decoder->DispatchCreateHardwareBufferCommand(header.thread_id,
0u,
0u,
header.memory_id,
header.buffer_id,
header.format,
Expand Down Expand Up @@ -1010,6 +1085,8 @@ bool FileProcessor::ProcessMetaData(const format::BlockHeader& block_header, for
format::CreateHardwareBufferCommandHeader header;

success = ReadBytes(&header.thread_id, sizeof(header.thread_id));
success = success && ReadBytes(&header.device_id, sizeof(header.device_id));
success = success && ReadBytes(&header.queue_id, sizeof(header.queue_id));
success = success && ReadBytes(&header.memory_id, sizeof(header.memory_id));
success = success && ReadBytes(&header.buffer_id, sizeof(header.buffer_id));
success = success && ReadBytes(&header.format, sizeof(header.format));
Expand Down Expand Up @@ -1044,6 +1121,8 @@ bool FileProcessor::ProcessMetaData(const format::BlockHeader& block_header, for
if (decoder->SupportsMetaDataId(meta_data_id))
{
decoder->DispatchCreateHardwareBufferCommand(header.thread_id,
header.device_id,
header.queue_id,
header.memory_id,
header.buffer_id,
header.format,
Expand Down
2 changes: 2 additions & 0 deletions framework/decode/info_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class InfoDecoder : public ApiDecoder

virtual void
DispatchCreateHardwareBufferCommand(format::ThreadId thread_id,
format::HandleId device_id,
format::HandleId queue_id,
format::HandleId memory_id,
uint64_t buffer_id,
uint32_t format,
Expand Down
4 changes: 3 additions & 1 deletion framework/decode/metadata_consumer_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ class MetadataConsumerBase
virtual void
ProcessResizeWindowCommand2(format::HandleId surface_id, uint32_t width, uint32_t height, uint32_t pre_transform)
{}
virtual void ProcessCreateHardwareBufferCommand(format::HandleId memory_id,
virtual void ProcessCreateHardwareBufferCommand(format::HandleId device_id,
format::HandleId queue_id,
format::HandleId memory_id,
uint64_t buffer_id,
uint32_t format,
uint32_t width,
Expand Down
6 changes: 5 additions & 1 deletion framework/decode/metadata_json_consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ class MetadataJsonConsumer : public Base
}

virtual void
ProcessCreateHardwareBufferCommand(format::HandleId memory_id,
ProcessCreateHardwareBufferCommand(format::HandleId device_id,
format::HandleId queue_id,
format::HandleId memory_id,
uint64_t buffer_id,
uint32_t format,
uint32_t width,
Expand All @@ -133,6 +135,8 @@ class MetadataJsonConsumer : public Base
{
const util::JsonOptions& json_options = GetOptions();
auto& jdata = WriteMetaCommandStart("CreateHardwareBufferCommand");
HandleToJson(jdata["device_id"], device_id, json_options);
HandleToJson(jdata["queue_id"], queue_id, json_options);
HandleToJson(jdata["memory_id"], memory_id, json_options);
HandleToJson(jdata["buffer_id"], buffer_id, json_options);
FieldToJson(jdata["format"], format, json_options);
Expand Down
2 changes: 2 additions & 0 deletions framework/decode/stat_decoder_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class StatDecoderBase : public ApiDecoder

virtual void
DispatchCreateHardwareBufferCommand(format::ThreadId thread_id,
format::HandleId device_id,
format::HandleId queue_id,
format::HandleId memory_id,
uint64_t buffer_id,
uint32_t format,
Expand Down
2 changes: 2 additions & 0 deletions framework/decode/vulkan_cpp_consumer_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3143,6 +3143,8 @@ void VulkanCppConsumerBase::ProcessResizeWindowCommand2(format::HandleId surface
}

void VulkanCppConsumerBase::ProcessCreateHardwareBufferCommand(
format::HandleId device_id,
format::HandleId queue_id,
format::HandleId memory_id,
uint64_t buffer_id,
uint32_t format,
Expand Down
4 changes: 3 additions & 1 deletion framework/decode/vulkan_cpp_consumer_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,9 @@ class VulkanCppConsumerBase : public VulkanConsumer
uint32_t height,
uint32_t pre_transform) override;
virtual void
ProcessCreateHardwareBufferCommand(format::HandleId memory_id,
ProcessCreateHardwareBufferCommand(format::HandleId device_id,
format::HandleId queue_id,
format::HandleId memory_id,
uint64_t buffer_id,
uint32_t format,
uint32_t width,
Expand Down
4 changes: 3 additions & 1 deletion framework/decode/vulkan_decoder_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ void VulkanDecoderBase::DispatchResizeWindowCommand2(

void VulkanDecoderBase::DispatchCreateHardwareBufferCommand(
format::ThreadId thread_id,
format::HandleId device_id,
format::HandleId queue_id,
format::HandleId memory_id,
uint64_t buffer_id,
uint32_t format,
Expand All @@ -141,7 +143,7 @@ void VulkanDecoderBase::DispatchCreateHardwareBufferCommand(
for (auto consumer : consumers_)
{
consumer->ProcessCreateHardwareBufferCommand(
memory_id, buffer_id, format, width, height, stride, usage, layers, plane_info);
device_id, queue_id, memory_id, buffer_id, format, width, height, stride, usage, layers, plane_info);
}
}

Expand Down
2 changes: 2 additions & 0 deletions framework/decode/vulkan_decoder_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ class VulkanDecoderBase : public ApiDecoder

virtual void
DispatchCreateHardwareBufferCommand(format::ThreadId thread_id,
format::HandleId device_id,
format::HandleId queue_id,
format::HandleId memory_id,
uint64_t buffer_id,
uint32_t format,
Expand Down
Loading

0 comments on commit 1763e52

Please sign in to comment.