material_storage.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /**************************************************************************/
  2. /* material_storage.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef MATERIAL_STORAGE_DUMMY_H
  31. #define MATERIAL_STORAGE_DUMMY_H
  32. #include "servers/rendering/shader_compiler.h"
  33. #include "servers/rendering/shader_language.h"
  34. #include "servers/rendering/storage/material_storage.h"
  35. #include "servers/rendering/storage/utilities.h"
  36. namespace RendererDummy {
  37. class MaterialStorage : public RendererMaterialStorage {
  38. private:
  39. static MaterialStorage *singleton;
  40. struct DummyShader {
  41. HashMap<StringName, ShaderLanguage::ShaderNode::Uniform> uniforms;
  42. };
  43. mutable RID_Owner<DummyShader> shader_owner;
  44. ShaderCompiler dummy_compiler;
  45. public:
  46. static MaterialStorage *get_singleton() { return singleton; }
  47. MaterialStorage();
  48. ~MaterialStorage();
  49. /* GLOBAL SHADER UNIFORM API */
  50. virtual void global_shader_parameter_add(const StringName &p_name, RS::GlobalShaderParameterType p_type, const Variant &p_value) override {}
  51. virtual void global_shader_parameter_remove(const StringName &p_name) override {}
  52. virtual Vector<StringName> global_shader_parameter_get_list() const override { return Vector<StringName>(); }
  53. virtual void global_shader_parameter_set(const StringName &p_name, const Variant &p_value) override {}
  54. virtual void global_shader_parameter_set_override(const StringName &p_name, const Variant &p_value) override {}
  55. virtual Variant global_shader_parameter_get(const StringName &p_name) const override { return Variant(); }
  56. virtual RS::GlobalShaderParameterType global_shader_parameter_get_type(const StringName &p_name) const override { return RS::GLOBAL_VAR_TYPE_MAX; }
  57. virtual void global_shader_parameters_load_settings(bool p_load_textures = true) override {}
  58. virtual void global_shader_parameters_clear() override {}
  59. virtual int32_t global_shader_parameters_instance_allocate(RID p_instance) override { return 0; }
  60. virtual void global_shader_parameters_instance_free(RID p_instance) override {}
  61. virtual void global_shader_parameters_instance_update(RID p_instance, int p_index, const Variant &p_value, int p_flags_count = 0) override {}
  62. /* SHADER API */
  63. bool owns_shader(RID p_rid) { return shader_owner.owns(p_rid); }
  64. virtual RID shader_allocate() override;
  65. virtual void shader_initialize(RID p_rid) override;
  66. virtual void shader_free(RID p_rid) override;
  67. virtual void shader_set_code(RID p_shader, const String &p_code) override;
  68. virtual void shader_set_path_hint(RID p_shader, const String &p_code) override {}
  69. virtual String shader_get_code(RID p_shader) const override { return ""; }
  70. virtual void get_shader_parameter_list(RID p_shader, List<PropertyInfo> *p_param_list) const override;
  71. virtual void shader_set_default_texture_parameter(RID p_shader, const StringName &p_name, RID p_texture, int p_index) override {}
  72. virtual RID shader_get_default_texture_parameter(RID p_shader, const StringName &p_name, int p_index) const override { return RID(); }
  73. virtual Variant shader_get_parameter_default(RID p_material, const StringName &p_param) const override { return Variant(); }
  74. virtual RS::ShaderNativeSourceCode shader_get_native_source_code(RID p_shader) const override { return RS::ShaderNativeSourceCode(); }
  75. /* MATERIAL API */
  76. virtual RID material_allocate() override { return RID(); }
  77. virtual void material_initialize(RID p_rid) override {}
  78. virtual void material_free(RID p_rid) override {}
  79. virtual void material_set_render_priority(RID p_material, int priority) override {}
  80. virtual void material_set_shader(RID p_shader_material, RID p_shader) override {}
  81. virtual void material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) override {}
  82. virtual Variant material_get_param(RID p_material, const StringName &p_param) const override { return Variant(); }
  83. virtual void material_set_next_pass(RID p_material, RID p_next_material) override {}
  84. virtual bool material_is_animated(RID p_material) override { return false; }
  85. virtual bool material_casts_shadows(RID p_material) override { return false; }
  86. virtual void material_get_instance_shader_parameters(RID p_material, List<InstanceShaderParam> *r_parameters) override {}
  87. virtual void material_update_dependency(RID p_material, DependencyTracker *p_instance) override {}
  88. };
  89. } // namespace RendererDummy
  90. #endif // MATERIAL_STORAGE_DUMMY_H