mirror of
https://github.com/godotengine/godot.git
synced 2024-11-21 19:42:43 +00:00
fix headless import attempting to load graphics driver
This commit is contained in:
parent
92e51fca72
commit
2e1fc241f9
@ -36,11 +36,16 @@
|
|||||||
|
|
||||||
#include "bc1.glsl.gen.h"
|
#include "bc1.glsl.gen.h"
|
||||||
#include "bc6h.glsl.gen.h"
|
#include "bc6h.glsl.gen.h"
|
||||||
|
#include "servers/display_server.h"
|
||||||
|
|
||||||
static Mutex betsy_mutex;
|
static Mutex betsy_mutex;
|
||||||
static BetsyCompressor *betsy = nullptr;
|
static BetsyCompressor *betsy = nullptr;
|
||||||
|
|
||||||
void BetsyCompressor::_init() {
|
void BetsyCompressor::_init() {
|
||||||
|
if (!DisplayServer::can_create_rendering_device()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Create local RD.
|
// Create local RD.
|
||||||
RenderingContextDriver *rcd = nullptr;
|
RenderingContextDriver *rcd = nullptr;
|
||||||
RenderingDevice *rd = RenderingServer::get_singleton()->create_local_rendering_device();
|
RenderingDevice *rd = RenderingServer::get_singleton()->create_local_rendering_device();
|
||||||
@ -177,6 +182,11 @@ static String get_shader_name(BetsyFormat p_format) {
|
|||||||
Error BetsyCompressor::_compress(BetsyFormat p_format, Image *r_img) {
|
Error BetsyCompressor::_compress(BetsyFormat p_format, Image *r_img) {
|
||||||
uint64_t start_time = OS::get_singleton()->get_ticks_msec();
|
uint64_t start_time = OS::get_singleton()->get_ticks_msec();
|
||||||
|
|
||||||
|
// Return an error so that the compression can fall back to cpu compression
|
||||||
|
if (compress_rd == nullptr) {
|
||||||
|
return ERR_CANT_CREATE;
|
||||||
|
}
|
||||||
|
|
||||||
if (r_img->is_compressed()) {
|
if (r_img->is_compressed()) {
|
||||||
return ERR_INVALID_DATA;
|
return ERR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
|
@ -1229,6 +1229,10 @@ void DisplayServer::_input_set_custom_mouse_cursor_func(const Ref<Resource> &p_i
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DisplayServer::can_create_rendering_device() {
|
bool DisplayServer::can_create_rendering_device() {
|
||||||
|
if (get_singleton()->get_name() == "headless") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(RD_ENABLED)
|
#if defined(RD_ENABLED)
|
||||||
RenderingDevice *device = RenderingDevice::get_singleton();
|
RenderingDevice *device = RenderingDevice::get_singleton();
|
||||||
if (device) {
|
if (device) {
|
||||||
|
@ -31,7 +31,10 @@
|
|||||||
#include "rendering_device_binds.h"
|
#include "rendering_device_binds.h"
|
||||||
|
|
||||||
Error RDShaderFile::parse_versions_from_text(const String &p_text, const String p_defines, OpenIncludeFunction p_include_func, void *p_include_func_userdata) {
|
Error RDShaderFile::parse_versions_from_text(const String &p_text, const String p_defines, OpenIncludeFunction p_include_func, void *p_include_func_userdata) {
|
||||||
ERR_FAIL_NULL_V(RenderingDevice::get_singleton(), ERR_UNAVAILABLE);
|
ERR_FAIL_NULL_V_MSG(
|
||||||
|
RenderingDevice::get_singleton(),
|
||||||
|
ERR_UNAVAILABLE,
|
||||||
|
"Cannot import custom .glsl shaders when running without a RenderingDevice. This can happen if you are using the headless more or the Compatibility backend.");
|
||||||
|
|
||||||
Vector<String> lines = p_text.split("\n");
|
Vector<String> lines = p_text.split("\n");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user