Skip to content

Commit

Permalink
workaround for shaderc bug in PrintFilteredErrors()
Browse files Browse the repository at this point in the history
  • Loading branch information
beaumanvienna committed Jun 6, 2024
1 parent f51f1ad commit 7305b0c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ MessageType ParseGlslangOutput(const shaderc_util::string_piece& message,
bool PrintFilteredErrors(const shaderc_util::string_piece& file_name,
std::ostream* error_stream, bool warnings_as_errors,
bool suppress_warnings, const char* error_list,
size_t* total_warnings, size_t* total_errors);
size_t* total_warnings, size_t* total_errors,
bool success = true);

// Outputs, to error_stream, the number of warnings and errors if there are
// any.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <cstring>
#include <ostream>
#include <vector>
#include <iostream>

namespace shaderc_util {
// Provides a read-only view into a string (cstring or std::string).
Expand Down Expand Up @@ -311,6 +312,32 @@ class string_piece {
}
return fields;
}

std::vector<string_piece> get_fields(bool success, char delimiter,
bool keep_delimiter = false) const {
std::vector<string_piece> fields;
size_t first = 0;
size_t field_break = find_first_of(delimiter);
while (field_break != npos) {
string_piece element = substr(first, field_break - first + keep_delimiter);
if (!success)
{
std::cout << element.data() << "\n";
}
fields.push_back(element);
first = field_break + 1;
field_break = find_first_of(delimiter, first);
}
if (size() - first > 0) {
fields.push_back(substr(first, size() - first));
}
if (!success)
{
std::cout << "shader comilation failed - terminating\n";
exit(0);
}
return fields;
}

friend std::ostream& operator<<(std::ostream& os, const string_piece& piece);

Expand Down
2 changes: 1 addition & 1 deletion vendor/shaderc/libshaderc_util/src/compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ std::tuple<bool, std::vector<uint32_t>, size_t> Compiler::Compile(

success &= PrintFilteredErrors(error_tag, error_stream, warnings_as_errors_,
suppress_warnings_, shader.getInfoLog(),
total_warnings, total_errors);
total_warnings, total_errors, success);
if (!success) return result_tuple;

glslang::TProgram program;
Expand Down
5 changes: 3 additions & 2 deletions vendor/shaderc/libshaderc_util/src/message.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ MessageType ParseGlslangOutput(const string_piece& message,
bool PrintFilteredErrors(const string_piece& file_name,
std::ostream* error_stream, bool warnings_as_errors,
bool suppress_warnings, const char* error_list,
size_t* total_warnings, size_t* total_errors) {
size_t* total_warnings, size_t* total_errors,
bool success) {
const char* ignored_error_strings[] = {
"Warning, version 310 is not yet complete; most version-specific "
"features are present, but some are missing.",
Expand All @@ -219,7 +220,7 @@ bool PrintFilteredErrors(const string_piece& file_name,
"Linked compute stage:", ""};
size_t existing_total_errors = *total_errors;
string_piece error_messages(error_list);
for (const string_piece& message : error_messages.get_fields('\n')) {
for (const string_piece& message : error_messages.get_fields(success, '\n')) {
if (std::find(std::begin(ignored_error_strings),
std::end(ignored_error_strings),
message) == std::end(ignored_error_strings)) {
Expand Down

0 comments on commit 7305b0c

Please sign in to comment.