Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse OpenGL and Vulkan strings as UTF-8. #84197

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions drivers/gles3/shader_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ void ShaderGLES3::_setup(const char *p_vertex_code, const char *p_fragment_code,
tohash.append(p_fragment_code ? p_fragment_code : "");

tohash.append("[gl_implementation]");
const char *vendor = (const char *)glGetString(GL_VENDOR);
tohash.append(vendor ? vendor : "unknown");
const char *renderer = (const char *)glGetString(GL_RENDERER);
tohash.append(renderer ? renderer : "unknown");
const char *version = (const char *)glGetString(GL_VERSION);
tohash.append(version ? version : "unknown");
const String &vendor = String::utf8((const char *)glGetString(GL_VENDOR));
tohash.append(vendor.is_empty() ? "unknown" : vendor);
const String &renderer = String::utf8((const char *)glGetString(GL_RENDERER));
tohash.append(renderer.is_empty() ? "unknown" : renderer);
const String &version = String::utf8((const char *)glGetString(GL_VERSION));
tohash.append(version.is_empty() ? "unknown" : version);

base_sha256 = tohash.as_string().sha256_text();
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/gles3/storage/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Config::Config() {
if (use_depth_prepass) {
String vendors = GLOBAL_GET("rendering/driver/depth_prepass/disable_for_vendors");
Vector<String> vendor_match = vendors.split(",");
String renderer = (const char *)glGetString(GL_RENDERER);
const String &renderer = String::utf8((const char *)glGetString(GL_RENDERER));
for (int i = 0; i < vendor_match.size(); i++) {
String v = vendor_match[i].strip_edges();
if (v == String()) {
Expand Down
6 changes: 3 additions & 3 deletions drivers/gles3/storage/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,13 @@ uint64_t Utilities::get_rendering_info(RS::RenderingInfo p_info) {
}

String Utilities::get_video_adapter_name() const {
const String rendering_device_name = (const char *)glGetString(GL_RENDERER);
const String rendering_device_name = String::utf8((const char *)glGetString(GL_RENDERER));
// NVIDIA suffixes all GPU model names with "/PCIe/SSE2" in OpenGL (but not Vulkan). This isn't necessary to display nowadays, so it can be trimmed.
return rendering_device_name.trim_suffix("/PCIe/SSE2");
}

String Utilities::get_video_adapter_vendor() const {
const String rendering_device_vendor = (const char *)glGetString(GL_VENDOR);
const String rendering_device_vendor = String::utf8((const char *)glGetString(GL_VENDOR));
// NVIDIA suffixes its vendor name with " Corporation". This is neither necessary to process nor display.
return rendering_device_vendor.trim_suffix(" Corporation");
}
Expand All @@ -388,7 +388,7 @@ RenderingDevice::DeviceType Utilities::get_video_adapter_type() const {
}

String Utilities::get_video_adapter_api_version() const {
return (const char *)glGetString(GL_VERSION);
return String::utf8((const char *)glGetString(GL_VERSION));
}

Size2i Utilities::get_maximum_viewport_size() const {
Expand Down
16 changes: 8 additions & 8 deletions drivers/vulkan/vulkan_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ Error VulkanContext::_initialize_instance_extensions() {
}
#ifdef DEV_ENABLED
for (uint32_t i = 0; i < instance_extension_count; i++) {
print_verbose(String("VULKAN: Found instance extension ") + String(instance_extensions[i].extensionName));
print_verbose(String("VULKAN: Found instance extension ") + String::utf8(instance_extensions[i].extensionName));
}
#endif

Expand All @@ -465,9 +465,9 @@ Error VulkanContext::_initialize_instance_extensions() {
if (!enabled_instance_extension_names.has(requested_extension.key)) {
if (requested_extension.value) {
free(instance_extensions);
ERR_FAIL_V_MSG(ERR_BUG, String("Required extension ") + String(requested_extension.key) + String(" not found, is a driver installed?"));
ERR_FAIL_V_MSG(ERR_BUG, String("Required extension ") + String::utf8(requested_extension.key) + String(" not found, is a driver installed?"));
} else {
print_verbose(String("Optional extension ") + String(requested_extension.key) + String(" not found"));
print_verbose(String("Optional extension ") + String::utf8(requested_extension.key) + String(" not found"));
}
}
}
Expand Down Expand Up @@ -546,7 +546,7 @@ Error VulkanContext::_initialize_device_extensions() {

#ifdef DEV_ENABLED
for (uint32_t i = 0; i < device_extension_count; i++) {
print_verbose(String("VULKAN: Found device extension ") + String(device_extensions[i].extensionName));
print_verbose(String("VULKAN: Found device extension ") + String::utf8(device_extensions[i].extensionName));
}
#endif

Expand All @@ -564,9 +564,9 @@ Error VulkanContext::_initialize_device_extensions() {
if (requested_extension.value) {
free(device_extensions);
ERR_FAIL_V_MSG(ERR_BUG,
String("vkEnumerateDeviceExtensionProperties failed to find the ") + String(requested_extension.key) + String(" extension.\n\nDo you have a compatible Vulkan installable client driver (ICD) installed?\nvkCreateInstance Failure"));
String("vkEnumerateDeviceExtensionProperties failed to find the ") + String::utf8(requested_extension.key) + String(" extension.\n\nDo you have a compatible Vulkan installable client driver (ICD) installed?\nvkCreateInstance Failure"));
} else {
print_verbose(String("Optional extension ") + String(requested_extension.key) + String(" not found"));
print_verbose(String("Optional extension ") + String::utf8(requested_extension.key) + String(" not found"));
}
}
}
Expand Down Expand Up @@ -1248,7 +1248,7 @@ Error VulkanContext::_create_physical_device(VkSurfaceKHR p_surface) {
}
}
}
String name = props.deviceName;
String name = String::utf8(props.deviceName);
String vendor = "Unknown";
String dev_type;
switch (props.deviceType) {
Expand Down Expand Up @@ -1330,7 +1330,7 @@ Error VulkanContext::_create_physical_device(VkSurfaceKHR p_surface) {
// Get identifier properties.
vkGetPhysicalDeviceProperties(gpu, &gpu_props);

device_name = gpu_props.deviceName;
device_name = String::utf8(gpu_props.deviceName);
device_type = gpu_props.deviceType;
pipeline_cache_id = String::hex_encode_buffer(gpu_props.pipelineCacheUUID, VK_UUID_SIZE);
pipeline_cache_id += "-driver-" + itos(gpu_props.driverVersion);
Expand Down
Loading