mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
Gfx binding (#2898)
This commit is contained in:
+31
-31
@@ -575,43 +575,43 @@ It should work same as apples CFSwapInt32LittleToHost(..)
|
||||
#endif
|
||||
|
||||
// Engine Memory Management
|
||||
#if (CC_PLATFORM == CC_PLATFORM_WINDOWS)
|
||||
#if (CC_MODE == CC_MODE_DEBUG)
|
||||
#define CC_MEMORY_TRACKER
|
||||
#endif
|
||||
#elif (CC_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
//# define CC_MEMORY_TRACKER
|
||||
#else
|
||||
#endif
|
||||
// #if (CC_PLATFORM == CC_PLATFORM_WINDOWS)
|
||||
// #if (CC_MODE == CC_MODE_DEBUG)
|
||||
// #define CC_MEMORY_TRACKER
|
||||
// #endif
|
||||
// #elif (CC_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
// //# define CC_MEMORY_TRACKER
|
||||
// #else
|
||||
// #endif
|
||||
|
||||
// use simd
|
||||
//#define CC_USE_SIMD
|
||||
|
||||
// Memory Allocator
|
||||
#if (CC_PLATFORM == CC_PLATFORM_WINDOWS)
|
||||
#define CC_MEMORY_ALLOCATOR CC_MEMORY_ALLOCATOR_STD
|
||||
#undef CC_MEMORY_TRACKER
|
||||
//#if defined(CC_MEMORY_TRACKER)
|
||||
//# define CC_MEMORY_ALLOCATOR CC_MEMORY_ALLOCATOR_JEMALLOC
|
||||
//#else
|
||||
//# define CC_MEMORY_ALLOCATOR CC_MEMORY_ALLOCATOR_STD
|
||||
//#endif
|
||||
#elif (CC_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
#if defined(CC_MEMORY_TRACKER)
|
||||
#define CC_MEMORY_ALLOCATOR CC_MEMORY_ALLOCATOR_JEMALLOC
|
||||
#else
|
||||
#define CC_MEMORY_ALLOCATOR CC_MEMORY_ALLOCATOR_STD
|
||||
#endif
|
||||
#else
|
||||
#define CC_MEMORY_ALLOCATOR CC_MEMORY_ALLOCATOR_STD
|
||||
#endif
|
||||
// #if (CC_PLATFORM == CC_PLATFORM_WINDOWS)
|
||||
// #define CC_MEMORY_ALLOCATOR CC_MEMORY_ALLOCATOR_STD
|
||||
// #undef CC_MEMORY_TRACKER
|
||||
// //#if defined(CC_MEMORY_TRACKER)
|
||||
// //# define CC_MEMORY_ALLOCATOR CC_MEMORY_ALLOCATOR_JEMALLOC
|
||||
// //#else
|
||||
// //# define CC_MEMORY_ALLOCATOR CC_MEMORY_ALLOCATOR_STD
|
||||
// //#endif
|
||||
// #elif (CC_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
// #if defined(CC_MEMORY_TRACKER)
|
||||
// #define CC_MEMORY_ALLOCATOR CC_MEMORY_ALLOCATOR_JEMALLOC
|
||||
// #else
|
||||
// #define CC_MEMORY_ALLOCATOR CC_MEMORY_ALLOCATOR_STD
|
||||
// #endif
|
||||
// #else
|
||||
// #define CC_MEMORY_ALLOCATOR CC_MEMORY_ALLOCATOR_STD
|
||||
// #endif
|
||||
|
||||
// STL memory allocator
|
||||
#if (CC_MEMORY_ALLOCATOR == CC_MEMORY_ALLOCATOR_STD)
|
||||
#define CC_STL_MEMORY_ALLOCATOR CC_STL_MEMORY_ALLOCATOR_STANDARD
|
||||
#else
|
||||
#define CC_STL_MEMORY_ALLOCATOR CC_STL_MEMORY_ALLOCATOR_CUSTOM
|
||||
#endif
|
||||
// // STL memory allocator
|
||||
// #if (CC_MEMORY_ALLOCATOR == CC_MEMORY_ALLOCATOR_STD)
|
||||
// #define CC_STL_MEMORY_ALLOCATOR CC_STL_MEMORY_ALLOCATOR_STANDARD
|
||||
// #else
|
||||
// #define CC_STL_MEMORY_ALLOCATOR CC_STL_MEMORY_ALLOCATOR_CUSTOM
|
||||
// #endif
|
||||
|
||||
#define CC_TOSTR(s) #s
|
||||
|
||||
|
||||
@@ -38,84 +38,6 @@
|
||||
#define GFX_INVALID_BINDING ((uint8_t)-1)
|
||||
#define GFX_INVALID_HANDLE ((uint)-1)
|
||||
|
||||
se::Object *__jsb_cc_gfx_BindingMappingInfo_proto = nullptr;
|
||||
se::Class *__jsb_cc_gfx_BindingMappingInfo_class = nullptr;
|
||||
|
||||
SE_DECLARE_FINALIZE_FUNC(js_cc_gfx_BindingMappingInfo_finalize)
|
||||
|
||||
static bool js_gfx_BindingMappingInfo_constructor(se::State &s) {
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto &args = s.args();
|
||||
size_t argc = args.size();
|
||||
|
||||
if (argc == 0) {
|
||||
cc::gfx::BindingMappingInfo *cobj = JSB_ALLOC(cc::gfx::BindingMappingInfo);
|
||||
s.thisObject()->setPrivateData(cobj);
|
||||
se::NonRefNativePtrCreatedByCtorMap::emplace(cobj);
|
||||
return true;
|
||||
} else if (argc == 1 && args[0].isObject()) {
|
||||
|
||||
se::Object *json = args[0].toObject();
|
||||
se::Value field;
|
||||
|
||||
cc::gfx::BindingMappingInfo *cobj = JSB_ALLOC(cc::gfx::BindingMappingInfo);
|
||||
s.thisObject()->setPrivateData(cobj);
|
||||
se::NonRefNativePtrCreatedByCtorMap::emplace(cobj);
|
||||
|
||||
json->getProperty("bufferOffsets", &field);
|
||||
if (!field.isUndefined()) {
|
||||
ok &= seval_to_std_vector(field, &cobj->bufferOffsets);
|
||||
}
|
||||
|
||||
json->getProperty("samplerOffsets", &field);
|
||||
if (!field.isUndefined()) {
|
||||
ok &= seval_to_std_vector(field, &cobj->samplerOffsets);
|
||||
}
|
||||
|
||||
json->getProperty("flexibleSet", &field);
|
||||
if (!field.isUndefined()) {
|
||||
ok &= seval_to_uint32(field, &cobj->flexibleSet);
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
JSB_FREE(cobj);
|
||||
SE_REPORT_ERROR("Argument convertion error");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc);
|
||||
return false;
|
||||
}
|
||||
SE_BIND_CTOR(js_gfx_BindingMappingInfo_constructor, __jsb_cc_gfx_BindingMappingInfo_class, js_cc_gfx_BindingMappingInfo_finalize)
|
||||
|
||||
static bool js_cc_gfx_BindingMappingInfo_finalize(se::State &s) {
|
||||
auto iter = se::NonRefNativePtrCreatedByCtorMap::find(s.nativeThisObject());
|
||||
if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) {
|
||||
se::NonRefNativePtrCreatedByCtorMap::erase(iter);
|
||||
cc::gfx::BindingMappingInfo *cobj = (cc::gfx::BindingMappingInfo *)s.nativeThisObject();
|
||||
JSB_FREE(cobj);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FINALIZE_FUNC(js_cc_gfx_BindingMappingInfo_finalize)
|
||||
|
||||
bool js_register_gfx_BindingMappingInfo(se::Object *obj) {
|
||||
auto cls = se::Class::create("BindingMappingInfo", obj, nullptr, _SE(js_gfx_BindingMappingInfo_constructor));
|
||||
|
||||
cls->defineFinalizeFunction(_SE(js_cc_gfx_BindingMappingInfo_finalize));
|
||||
cls->install();
|
||||
JSBClassType::registerClass<cc::gfx::BindingMappingInfo>(cls);
|
||||
|
||||
__jsb_cc_gfx_BindingMappingInfo_proto = cls->getProto();
|
||||
__jsb_cc_gfx_BindingMappingInfo_class = cls;
|
||||
|
||||
se::ScriptEngine::getInstance()->clearException();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool js_gfx_Device_copyBuffersToTexture(se::State &s) {
|
||||
cc::gfx::Device *cobj = (cc::gfx::Device *)s.nativeThisObject();
|
||||
SE_PRECONDITION2(cobj, false, "js_gfx_Device_copyBuffersToTexture : Invalid Native Object");
|
||||
@@ -915,7 +837,6 @@ bool register_all_gfx_manual(se::Object *obj) {
|
||||
}
|
||||
se::Object *ns = nsVal.toObject();
|
||||
|
||||
js_register_gfx_BindingMappingInfo(ns);
|
||||
js_register_gfx_SubPass(ns);
|
||||
|
||||
#ifdef CC_USE_VULKAN
|
||||
|
||||
@@ -508,7 +508,7 @@ enum class DynamicStateFlagBit : uint8_t {
|
||||
};
|
||||
typedef DynamicStateFlagBit DynamicStateFlags;
|
||||
|
||||
typedef vector<DynamicStateFlagBit> DynamicStateList;
|
||||
typedef cc::vector<DynamicStateFlagBit> DynamicStateList;
|
||||
|
||||
enum class StencilFace : uint8_t {
|
||||
FRONT,
|
||||
@@ -614,8 +614,8 @@ struct BufferTextureCopy {
|
||||
Extent texExtent = {0, 0, 1};
|
||||
TextureSubres texSubres;
|
||||
};
|
||||
typedef vector<BufferTextureCopy> BufferTextureCopyList;
|
||||
typedef vector<const uint8_t *> BufferDataList;
|
||||
typedef cc::vector<BufferTextureCopy> BufferTextureCopyList;
|
||||
typedef cc::vector<const uint8_t *> BufferDataList;
|
||||
|
||||
struct Viewport {
|
||||
int left = 0;
|
||||
@@ -650,7 +650,7 @@ struct Color {
|
||||
float w = 0.0f;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
typedef vector<Color> ColorList;
|
||||
typedef cc::vector<Color> ColorList;
|
||||
|
||||
/**
|
||||
* For non-vulkan backends, to maintain compatibility and maximize
|
||||
@@ -664,8 +664,8 @@ typedef vector<Color> ColorList;
|
||||
* offsets for each descriptor type in each set.
|
||||
*/
|
||||
struct BindingMappingInfo {
|
||||
vector<int> bufferOffsets;
|
||||
vector<int> samplerOffsets;
|
||||
cc::vector<int> bufferOffsets;
|
||||
cc::vector<int> samplerOffsets;
|
||||
uint flexibleSet = 0u;
|
||||
};
|
||||
|
||||
@@ -703,8 +703,8 @@ struct ContextInfo {
|
||||
struct BufferInfo {
|
||||
BufferUsage usage = BufferUsage::NONE;
|
||||
MemoryUsage memUsage = MemoryUsage::NONE;
|
||||
uint stride = 1;
|
||||
uint size = 0;
|
||||
uint stride = 1;
|
||||
BufferFlags flags = BufferFlagBit::NONE;
|
||||
};
|
||||
|
||||
@@ -726,7 +726,7 @@ struct DrawInfo {
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef vector<DrawInfo> DrawInfoList;
|
||||
typedef cc::vector<DrawInfo> DrawInfoList;
|
||||
|
||||
struct IndirectBuffer {
|
||||
DrawInfoList drawInfos;
|
||||
@@ -776,7 +776,7 @@ struct ShaderMacro {
|
||||
String value;
|
||||
};
|
||||
|
||||
typedef vector<ShaderMacro> ShaderMacroList;
|
||||
typedef cc::vector<ShaderMacro> ShaderMacroList;
|
||||
|
||||
struct Uniform {
|
||||
String name;
|
||||
@@ -784,7 +784,7 @@ struct Uniform {
|
||||
uint count = 0;
|
||||
};
|
||||
|
||||
typedef vector<Uniform> UniformList;
|
||||
typedef cc::vector<Uniform> UniformList;
|
||||
|
||||
struct UniformBlock {
|
||||
uint set = 0;
|
||||
@@ -794,7 +794,7 @@ struct UniformBlock {
|
||||
uint count = 0u;
|
||||
};
|
||||
|
||||
typedef vector<UniformBlock> UniformBlockList;
|
||||
typedef cc::vector<UniformBlock> UniformBlockList;
|
||||
|
||||
struct UniformSampler {
|
||||
uint set = 0;
|
||||
@@ -804,14 +804,14 @@ struct UniformSampler {
|
||||
uint count = 0;
|
||||
};
|
||||
|
||||
typedef vector<UniformSampler> UniformSamplerList;
|
||||
typedef cc::vector<UniformSampler> UniformSamplerList;
|
||||
|
||||
struct ShaderStage {
|
||||
ShaderStageFlagBit stage;
|
||||
String source;
|
||||
};
|
||||
|
||||
typedef vector<ShaderStage> ShaderStageList;
|
||||
typedef cc::vector<ShaderStage> ShaderStageList;
|
||||
|
||||
struct Attribute {
|
||||
String name;
|
||||
@@ -822,8 +822,8 @@ struct Attribute {
|
||||
uint location = 0;
|
||||
};
|
||||
|
||||
typedef vector<Attribute> AttributeList;
|
||||
typedef vector<Buffer *> BufferList;
|
||||
typedef cc::vector<Attribute> AttributeList;
|
||||
typedef cc::vector<Buffer *> BufferList;
|
||||
|
||||
struct ShaderInfo {
|
||||
String name;
|
||||
@@ -849,7 +849,7 @@ struct ColorAttachment {
|
||||
TextureLayout endLayout = TextureLayout::PRESENT_SRC;
|
||||
};
|
||||
|
||||
typedef vector<ColorAttachment> ColorAttachmentList;
|
||||
typedef cc::vector<ColorAttachment> ColorAttachmentList;
|
||||
|
||||
struct DepthStencilAttachment {
|
||||
Format format = Format::UNKNOWN;
|
||||
@@ -878,7 +878,7 @@ struct SubPass {
|
||||
}
|
||||
};
|
||||
|
||||
typedef vector<SubPass> SubPassList;
|
||||
typedef cc::vector<SubPass> SubPassList;
|
||||
|
||||
struct RenderPassInfo {
|
||||
ColorAttachmentList colorAttachments;
|
||||
@@ -886,14 +886,14 @@ struct RenderPassInfo {
|
||||
SubPassList subPasses;
|
||||
};
|
||||
|
||||
typedef vector<Buffer *> BufferList;
|
||||
typedef vector<Texture *> TextureList;
|
||||
typedef vector<Sampler *> SamplerList;
|
||||
typedef cc::vector<Buffer *> BufferList;
|
||||
typedef cc::vector<Texture *> TextureList;
|
||||
typedef cc::vector<Sampler *> SamplerList;
|
||||
|
||||
struct FramebufferInfo {
|
||||
RenderPass *renderPass = nullptr;
|
||||
TextureList colorTextures;
|
||||
vector<uint> colorMipmapLevels;
|
||||
cc::vector<uint> colorMipmapLevels;
|
||||
Texture *depthStencilTexture = nullptr;
|
||||
uint depthStencilMipmapLevel = 0;
|
||||
};
|
||||
@@ -904,7 +904,7 @@ struct DescriptorSetLayoutBinding {
|
||||
ShaderStageFlagBit stageFlags;
|
||||
SamplerList immutableSamplers;
|
||||
};
|
||||
typedef vector<DescriptorSetLayoutBinding> DescriptorSetLayoutBindingList;
|
||||
typedef cc::vector<DescriptorSetLayoutBinding> DescriptorSetLayoutBindingList;
|
||||
|
||||
struct DescriptorSetLayoutInfo {
|
||||
// array index is used as the binding numbers,
|
||||
@@ -916,7 +916,7 @@ struct DescriptorSetInfo {
|
||||
DescriptorSetLayout *layout = nullptr;
|
||||
};
|
||||
|
||||
typedef vector<DescriptorSetLayout *> DescriptorSetLayoutList;
|
||||
typedef cc::vector<DescriptorSetLayout *> DescriptorSetLayoutList;
|
||||
|
||||
struct PipelineLayoutInfo {
|
||||
DescriptorSetLayoutList setLayouts;
|
||||
@@ -974,7 +974,7 @@ struct BlendTarget {
|
||||
ColorMask blendColorMask = ColorMask::ALL;
|
||||
};
|
||||
|
||||
typedef vector<BlendTarget> BlendTargetList;
|
||||
typedef cc::vector<BlendTarget> BlendTargetList;
|
||||
|
||||
struct BlendState {
|
||||
bool isA2C = false;
|
||||
@@ -1004,7 +1004,7 @@ struct CommandBufferInfo {
|
||||
Queue *queue = nullptr;
|
||||
CommandBufferType type = CommandBufferType::PRIMARY;
|
||||
};
|
||||
typedef vector<CommandBuffer *> CommandBufferList;
|
||||
typedef cc::vector<CommandBuffer *> CommandBufferList;
|
||||
|
||||
struct QueueInfo {
|
||||
QueueType type = QueueType::GRAPHICS;
|
||||
|
||||
@@ -33,7 +33,7 @@ replace_headers =
|
||||
# what classes to produce code for. You can use regular expressions here. When testing the regular
|
||||
# expression, it will be enclosed in "^$", like this: "^Menu.*$".
|
||||
|
||||
classes = GFXObject Device Buffer CommandBuffer Framebuffer InputAssembler DescriptorSet DescriptorSetLayout PipelineLayout PipelineState Fence Queue RenderPass Sampler Shader Texture API Feature Format FormatType Type BufferUsageBit BufferFlagBit BufferAccessBit TextureUsageBit TextureFlagBit ShaderType TextureLayout QueueType CommandBufferType Offset Rect Extent TextureSubres TextureCopy BufferTextureCopy Viewport Color DeviceInfo ContextInfo BufferInfo BufferViewInfo DrawInfo IndirectBuffer TextureInfo TextureViewInfo SamplerInfo ShaderMacro Uniform UniformBlock UniformSampler ShaderStage ShaderInfo Attribute InputAssemblerInfo ColorAttachment DepthStencilAttachment RenderPassInfo FramebufferInfo DescriptorSetLayoutBinding DescriptorSetInfo DescriptorSetLayoutInfo PipelineLayoutInfo PushConstantRange InputState RasterizerState DepthStencilState BlendTarget BlendState PipelineStateInfo CommandBufferInfo QueueInfo FormatInfo MemoryStatus
|
||||
classes = GFXObject Device Buffer CommandBuffer Framebuffer InputAssembler DescriptorSet DescriptorSetLayout PipelineLayout PipelineState Fence Queue RenderPass Sampler Shader Texture API Feature Format FormatType Type BufferUsageBit BufferFlagBit BufferAccessBit TextureUsageBit TextureFlagBit ShaderType TextureLayout QueueType CommandBufferType Offset Rect Extent TextureSubres TextureCopy BufferTextureCopy Viewport Color DeviceInfo ContextInfo BufferInfo BufferViewInfo DrawInfo IndirectBuffer TextureInfo TextureViewInfo SamplerInfo ShaderMacro Uniform UniformBlock UniformSampler ShaderStage ShaderInfo Attribute InputAssemblerInfo ColorAttachment DepthStencilAttachment RenderPassInfo FramebufferInfo DescriptorSetLayoutBinding DescriptorSetInfo DescriptorSetLayoutInfo PipelineLayoutInfo PushConstantRange InputState RasterizerState DepthStencilState BlendTarget BlendState PipelineStateInfo CommandBufferInfo QueueInfo FormatInfo MemoryStatus BindingMappingInfo
|
||||
|
||||
classes_need_extend =
|
||||
|
||||
|
||||
Reference in New Issue
Block a user