1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef SCENE_INTERFACE_ISHADER_H 17 #define SCENE_INTERFACE_ISHADER_H 18 19 #include <scene/base/namespace.h> 20 #include <scene/base/types.h> 21 #include <scene/interface/intf_scene.h> 22 23 #include <render/device/intf_shader_manager.h> 24 #include <render/resource_handle.h> 25 26 #include <meta/base/interface_macros.h> 27 #include <meta/interface/interface_macros.h> 28 29 SCENE_BEGIN_NAMESPACE() 30 31 /** Cull mode flag bits */ 32 enum class CullModeFlags : uint32_t { 33 /** None */ 34 NONE = 0, 35 /** Front bit */ 36 FRONT_BIT = 0x00000001, 37 /** Back bit */ 38 BACK_BIT = 0x00000002, 39 /** Front and back bit */ 40 FRONT_AND_BACK = 0x00000003, 41 }; 42 43 inline CullModeFlags operator|(CullModeFlags l, CullModeFlags r) 44 { 45 return CullModeFlags(static_cast<uint32_t>(l) | static_cast<uint32_t>(r)); 46 } 47 48 class IShader : public CORE_NS::IInterface { 49 META_INTERFACE(CORE_NS::IInterface, IShader, "8a241b86-14c6-48ec-b450-6f9818f9f31a") 50 public: 51 META_PROPERTY(CullModeFlags, CullMode); 52 META_PROPERTY(bool, Blend); 53 }; 54 55 class IGraphicsState : public CORE_NS::IInterface { 56 META_INTERFACE(CORE_NS::IInterface, IGraphicsState, "6788f05b-4a55-4396-8cdd-115dc2958656") 57 public: 58 virtual bool SetGraphicsState(RENDER_NS::RenderHandleReference) = 0; 59 virtual RENDER_NS::RenderHandleReference GetGraphicsState() const = 0; 60 }; 61 62 class IShaderState : public CORE_NS::IInterface { 63 META_INTERFACE(CORE_NS::IInterface, IShaderState, "44b20afb-4e96-41de-a765-df9dd07799de") 64 public: 65 virtual bool SetShaderState(RENDER_NS::RenderHandleReference shader, RENDER_NS::RenderHandleReference graphics) = 0; 66 }; 67 68 META_REGISTER_CLASS(Shader, "56d686b8-7a33-4608-b12a-1a170381bcfd", META_NS::ObjectCategoryBits::NO_CATEGORY) 69 70 SCENE_END_NAMESPACE() 71 72 META_TYPE(SCENE_NS::CullModeFlags) 73 META_INTERFACE_TYPE(SCENE_NS::IShader) 74 META_INTERFACE_TYPE(SCENE_NS::IGraphicsState) 75 76 #endif 77