aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/amber/amber.h2
-rw-r--r--samples/amber.cc17
-rw-r--r--src/amber.cc4
3 files changed, 18 insertions, 5 deletions
diff --git a/include/amber/amber.h b/include/amber/amber.h
index 6360f37..2b14475 100644
--- a/include/amber/amber.h
+++ b/include/amber/amber.h
@@ -51,6 +51,8 @@ struct BufferInfo {
BufferInfo& operator=(const BufferInfo&);
+ /// Determines if this is an image buffer.
+ bool is_image_buffer;
/// Holds the buffer name
std::string buffer_name;
/// Holds the buffer width
diff --git a/samples/amber.cc b/samples/amber.cc
index 48e6771..8d185d0 100644
--- a/samples/amber.cc
+++ b/samples/amber.cc
@@ -40,6 +40,7 @@ struct Options {
std::string image_filename;
std::string buffer_filename;
+ std::string fb_name = kGeneratedColorBuffer;
std::vector<amber::BufferInfo> buffer_to_dump;
uint32_t engine_major = 1;
uint32_t engine_minor = 0;
@@ -65,6 +66,7 @@ const char kUsage[] = R"(Usage: amber [options] SCRIPT [SCRIPTS...]
-d -- Disable validation layers.
-t <spirv_env> -- The target SPIR-V environment. Defaults to SPV_ENV_UNIVERSAL_1_0.
-i <filename> -- Write rendering to <filename> as a PNG image if it ends with '.png', or as a PPM image otherwise.
+ -I <buffername> -- Name of framebuffer to dump. Defaults to 'framebuffer'.
-b <filename> -- Write contents of a UBO or SSBO to <filename>.
-B [<desc set>:]<binding> -- Descriptor set and binding of buffer to write.
Default is [0:]0.
@@ -88,6 +90,14 @@ bool ParseArgs(const std::vector<std::string>& args, Options* opts) {
}
opts->image_filename = args[i];
+ } else if (arg == "-I") {
+ ++i;
+ if (i >= args.size()) {
+ std::cerr << "Missing value for -I argument." << std::endl;
+ return false;
+ }
+ opts->fb_name = args[i];
+
} else if (arg == "-b") {
++i;
if (i >= args.size()) {
@@ -386,7 +396,8 @@ int main(int argc, const char** argv) {
if (!options.image_filename.empty()) {
amber::BufferInfo buffer_info;
- buffer_info.buffer_name = kGeneratedColorBuffer;
+ buffer_info.buffer_name = options.fb_name;
+ buffer_info.is_image_buffer = true;
amber_options.extractions.push_back(buffer_info);
}
@@ -410,7 +421,7 @@ int main(int argc, const char** argv) {
bool usePNG = pos != std::string::npos &&
options.image_filename.substr(pos + 1) == "png";
for (const amber::BufferInfo& buffer_info : amber_options.extractions) {
- if (buffer_info.buffer_name == kGeneratedColorBuffer) {
+ if (buffer_info.buffer_name == options.fb_name) {
if (usePNG) {
result = png::ConvertToPNG(buffer_info.width, buffer_info.height,
buffer_info.values, &out_buf);
@@ -446,7 +457,7 @@ int main(int argc, const char** argv) {
std::cerr << options.buffer_filename << std::endl;
} else {
for (const amber::BufferInfo& buffer_info : amber_options.extractions) {
- if (buffer_info.buffer_name == kGeneratedColorBuffer)
+ if (buffer_info.buffer_name == options.fb_name)
continue;
buffer_file << buffer_info.buffer_name << std::endl;
diff --git a/src/amber.cc b/src/amber.cc
index b8f41d2..183ebac 100644
--- a/src/amber.cc
+++ b/src/amber.cc
@@ -72,7 +72,7 @@ Options::Options()
Options::~Options() = default;
-BufferInfo::BufferInfo() : width(0), height(0) {}
+BufferInfo::BufferInfo() : is_image_buffer(false), width(0), height(0) {}
BufferInfo::BufferInfo(const BufferInfo&) = default;
@@ -189,7 +189,7 @@ amber::Result Amber::ExecuteWithShaderData(const amber::Recipe* recipe,
// extractor fails before running the pipeline that will trigger the dumps
// to almost always fail.
for (BufferInfo& buffer_info : opts->extractions) {
- if (buffer_info.buffer_name == Pipeline::kGeneratedColorBuffer) {
+ if (buffer_info.is_image_buffer) {
auto* buffer = script->GetBuffer(buffer_info.buffer_name);
if (!buffer)
break;