Fix #106672: MacOS/OpenGL doesn't draw anything Eevee related. #106887

Merged
Jeroen Bakker merged 2 commits from Sergey/blender:eevee-legacy-mac-ati-b into main 2023-04-13 10:18:55 +02:00
2 changed files with 33 additions and 5 deletions

View File

@ -405,7 +405,7 @@ static void print_resource(std::ostream &os,
array_offset = res.uniformbuf.name.find_first_of("[");
name_no_array = (array_offset == -1) ? res.uniformbuf.name :
StringRef(res.uniformbuf.name.c_str(), array_offset);
os << "uniform _" << name_no_array << " { " << res.uniformbuf.type_name << " "
os << "uniform " << name_no_array << " { " << res.uniformbuf.type_name << " _"
<< res.uniformbuf.name << "; };\n";
break;
case ShaderCreateInfo::Resource::BindType::STORAGE_BUFFER:
@ -413,13 +413,36 @@ static void print_resource(std::ostream &os,
name_no_array = (array_offset == -1) ? res.storagebuf.name :
StringRef(res.storagebuf.name.c_str(), array_offset);
print_qualifier(os, res.storagebuf.qualifiers);
os << "buffer _";
os << name_no_array << " { " << res.storagebuf.type_name << " " << res.storagebuf.name
os << "buffer ";
os << name_no_array << " { " << res.storagebuf.type_name << " _" << res.storagebuf.name
<< "; };\n";
break;
}
}
static void print_resource_alias(std::ostream &os, const ShaderCreateInfo::Resource &res)
{
int64_t array_offset;
StringRef name_no_array;
switch (res.bind_type) {
case ShaderCreateInfo::Resource::BindType::UNIFORM_BUFFER:
array_offset = res.uniformbuf.name.find_first_of("[");
name_no_array = (array_offset == -1) ? res.uniformbuf.name :
StringRef(res.uniformbuf.name.c_str(), array_offset);
os << "#define " << name_no_array << " (_" << name_no_array << ")\n";
break;
case ShaderCreateInfo::Resource::BindType::STORAGE_BUFFER:
array_offset = res.storagebuf.name.find_first_of("[");
name_no_array = (array_offset == -1) ? res.storagebuf.name :
StringRef(res.storagebuf.name.c_str(), array_offset);
os << "#define " << name_no_array << " (_" << name_no_array << ")\n";
break;
default:
break;
}
}
static void print_interface(std::ostream &os,
const StringRefNull &prefix,
const StageInterfaceInfo &iface,
@ -452,10 +475,16 @@ std::string GLShader::resources_declare(const ShaderCreateInfo &info) const
for (const ShaderCreateInfo::Resource &res : info.pass_resources_) {
print_resource(ss, res, info.auto_resource_location_);
}
for (const ShaderCreateInfo::Resource &res : info.pass_resources_) {
print_resource_alias(ss, res);
}
ss << "\n/* Batch Resources. */\n";
for (const ShaderCreateInfo::Resource &res : info.batch_resources_) {
print_resource(ss, res, info.auto_resource_location_);
}
for (const ShaderCreateInfo::Resource &res : info.batch_resources_) {
print_resource_alias(ss, res);
}
ss << "\n/* Push Constants. */\n";
for (const ShaderCreateInfo::PushConst &uniform : info.push_constants_) {
ss << "uniform " << to_string(uniform.type) << " " << uniform.name;

View File

@ -469,8 +469,7 @@ GLShaderInterface::GLShaderInterface(GLuint program, const shader::ShaderCreateI
if (res.bind_type == ShaderCreateInfo::Resource::BindType::UNIFORM_BUFFER) {
copy_input_name(input, res.uniformbuf.name, name_buffer_, name_buffer_offset);
if (true || !GLContext::explicit_location_support) {
std::string prefixed_name = "_" + res.uniformbuf.name;
input->location = glGetUniformBlockIndex(program, prefixed_name.c_str());
input->location = glGetUniformBlockIndex(program, name_buffer_ + input->name_offset);
glUniformBlockBinding(program, input->location, res.slot);
}
input->binding = res.slot;