unify gfx resize event (#3875)

This commit is contained in:
Yun Hsiao Wu
2021-09-09 16:00:21 +08:00
committed by GitHub
parent 548be02785
commit d4441705e6
26 changed files with 302 additions and 355 deletions
+134 -171
View File
@@ -15541,9 +15541,9 @@ bool js_register_gfx_GFXObject(se::Object* obj) // NOLINT(readability-identifier
{
auto* cls = se::Class::create("GFXObject", obj, nullptr, _SE(js_gfx_GFXObject_constructor));
cls->defineProperty("typedID", _SE(js_gfx_GFXObject_getTypedID), nullptr);
cls->defineProperty("objectID", _SE(js_gfx_GFXObject_getObjectID), nullptr);
cls->defineProperty("objectType", _SE(js_gfx_GFXObject_getObjectType), nullptr);
cls->defineProperty("objectID", _SE(js_gfx_GFXObject_getObjectID), nullptr);
cls->defineProperty("typedID", _SE(js_gfx_GFXObject_getTypedID), nullptr);
cls->defineFinalizeFunction(_SE(js_cc_gfx_GFXObject_finalize));
cls->install();
JSBClassType::registerClass<cc::gfx::GFXObject>(cls);
@@ -15773,12 +15773,12 @@ bool js_register_gfx_Buffer(se::Object* obj) // NOLINT(readability-identifier-na
{
auto* cls = se::Class::create("Buffer", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_Buffer_constructor));
cls->defineProperty("count", _SE(js_gfx_Buffer_getCount), nullptr);
cls->defineProperty("usage", _SE(js_gfx_Buffer_getUsage), nullptr);
cls->defineProperty("memUsage", _SE(js_gfx_Buffer_getMemUsage), nullptr);
cls->defineProperty("stride", _SE(js_gfx_Buffer_getStride), nullptr);
cls->defineProperty("flags", _SE(js_gfx_Buffer_getFlags), nullptr);
cls->defineProperty("usage", _SE(js_gfx_Buffer_getUsage), nullptr);
cls->defineProperty("count", _SE(js_gfx_Buffer_getCount), nullptr);
cls->defineProperty("size", _SE(js_gfx_Buffer_getSize), nullptr);
cls->defineProperty("flags", _SE(js_gfx_Buffer_getFlags), nullptr);
cls->defineFunction("destroy", _SE(js_gfx_Buffer_destroy));
cls->defineFunction("isBufferView", _SE(js_gfx_Buffer_isBufferView));
cls->defineFunction("resize", _SE(js_gfx_Buffer_resize));
@@ -16106,19 +16106,19 @@ bool js_register_gfx_InputAssembler(se::Object* obj) // NOLINT(readability-ident
{
auto* cls = se::Class::create("InputAssembler", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_InputAssembler_constructor));
cls->defineProperty("instanceCount", nullptr, _SE(js_gfx_InputAssembler_setInstanceCount));
cls->defineProperty("vertexBuffers", _SE(js_gfx_InputAssembler_getVertexBuffers), nullptr);
cls->defineProperty("attributesHash", _SE(js_gfx_InputAssembler_getAttributesHash), nullptr);
cls->defineProperty("firstInstance", nullptr, _SE(js_gfx_InputAssembler_setFirstInstance));
cls->defineProperty("vertexCount", nullptr, _SE(js_gfx_InputAssembler_setVertexCount));
cls->defineProperty("drawInfo", _SE(js_gfx_InputAssembler_getDrawInfo), nullptr);
cls->defineProperty("indexBuffer", _SE(js_gfx_InputAssembler_getIndexBuffer), nullptr);
cls->defineProperty("vertexOffset", nullptr, _SE(js_gfx_InputAssembler_setVertexOffset));
cls->defineProperty("attributes", _SE(js_gfx_InputAssembler_getAttributes), nullptr);
cls->defineProperty("indexBuffer", _SE(js_gfx_InputAssembler_getIndexBuffer), nullptr);
cls->defineProperty("indirectBuffer", _SE(js_gfx_InputAssembler_getIndirectBuffer), nullptr);
cls->defineProperty("attributesHash", _SE(js_gfx_InputAssembler_getAttributesHash), nullptr);
cls->defineProperty("drawInfo", _SE(js_gfx_InputAssembler_getDrawInfo), nullptr);
cls->defineProperty("vertexCount", nullptr, _SE(js_gfx_InputAssembler_setVertexCount));
cls->defineProperty("firstVertex", nullptr, _SE(js_gfx_InputAssembler_setFirstVertex));
cls->defineProperty("indexCount", nullptr, _SE(js_gfx_InputAssembler_setIndexCount));
cls->defineProperty("firstIndex", nullptr, _SE(js_gfx_InputAssembler_setFirstIndex));
cls->defineProperty("indirectBuffer", _SE(js_gfx_InputAssembler_getIndirectBuffer), nullptr);
cls->defineProperty("firstVertex", nullptr, _SE(js_gfx_InputAssembler_setFirstVertex));
cls->defineProperty("vertexOffset", nullptr, _SE(js_gfx_InputAssembler_setVertexOffset));
cls->defineProperty("instanceCount", nullptr, _SE(js_gfx_InputAssembler_setInstanceCount));
cls->defineProperty("firstInstance", nullptr, _SE(js_gfx_InputAssembler_setFirstInstance));
cls->defineFunction("destroy", _SE(js_gfx_InputAssembler_destroy));
cls->defineFunction("initialize", _SE(js_gfx_InputAssembler_initialize));
cls->defineFinalizeFunction(_SE(js_cc_gfx_InputAssembler_finalize));
@@ -17734,8 +17734,8 @@ bool js_register_gfx_Framebuffer(se::Object* obj) // NOLINT(readability-identifi
{
auto* cls = se::Class::create("Framebuffer", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_Framebuffer_constructor));
cls->defineProperty("colorTextures", _SE(js_gfx_Framebuffer_getColorTextures), nullptr);
cls->defineProperty("renderPass", _SE(js_gfx_Framebuffer_getRenderPass), nullptr);
cls->defineProperty("colorTextures", _SE(js_gfx_Framebuffer_getColorTextures), nullptr);
cls->defineProperty("depthStencilTexture", _SE(js_gfx_Framebuffer_getDepthStencilTexture), nullptr);
cls->defineFunction("destroy", _SE(js_gfx_Framebuffer_destroy));
cls->defineFunction("initialize", _SE(js_gfx_Framebuffer_initialize));
@@ -18104,14 +18104,14 @@ bool js_register_gfx_PipelineState(se::Object* obj) // NOLINT(readability-identi
{
auto* cls = se::Class::create("PipelineState", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_PipelineState_constructor));
cls->defineProperty("primitive", _SE(js_gfx_PipelineState_getPrimitive), nullptr);
cls->defineProperty("rasterizerState", _SE(js_gfx_PipelineState_getRasterizerState), nullptr);
cls->defineProperty("shader", _SE(js_gfx_PipelineState_getShader), nullptr);
cls->defineProperty("primitive", _SE(js_gfx_PipelineState_getPrimitive), nullptr);
cls->defineProperty("bindPoint", _SE(js_gfx_PipelineState_getBindPoint), nullptr);
cls->defineProperty("inputState", _SE(js_gfx_PipelineState_getInputState), nullptr);
cls->defineProperty("rasterizerState", _SE(js_gfx_PipelineState_getRasterizerState), nullptr);
cls->defineProperty("depthStencilState", _SE(js_gfx_PipelineState_getDepthStencilState), nullptr);
cls->defineProperty("blendState", _SE(js_gfx_PipelineState_getBlendState), nullptr);
cls->defineProperty("renderPass", _SE(js_gfx_PipelineState_getRenderPass), nullptr);
cls->defineProperty("inputState", _SE(js_gfx_PipelineState_getInputState), nullptr);
cls->defineProperty("bindPoint", _SE(js_gfx_PipelineState_getBindPoint), nullptr);
cls->defineProperty("depthStencilState", _SE(js_gfx_PipelineState_getDepthStencilState), nullptr);
cls->defineFunction("destroy", _SE(js_gfx_PipelineState_destroy));
cls->defineFunction("getDynamicStates", _SE(js_gfx_PipelineState_getDynamicStates));
cls->defineFunction("getPipelineLayout", _SE(js_gfx_PipelineState_getPipelineLayout));
@@ -18697,10 +18697,10 @@ bool js_register_gfx_Shader(se::Object* obj) // NOLINT(readability-identifier-na
{
auto* cls = se::Class::create("Shader", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_Shader_constructor));
cls->defineProperty("attributes", _SE(js_gfx_Shader_getAttributes), nullptr);
cls->defineProperty("stages", _SE(js_gfx_Shader_getStages), nullptr);
cls->defineProperty("blocks", _SE(js_gfx_Shader_getBlocks), nullptr);
cls->defineProperty("name", _SE(js_gfx_Shader_getName), nullptr);
cls->defineProperty("stages", _SE(js_gfx_Shader_getStages), nullptr);
cls->defineProperty("attributes", _SE(js_gfx_Shader_getAttributes), nullptr);
cls->defineProperty("blocks", _SE(js_gfx_Shader_getBlocks), nullptr);
cls->defineProperty("samplers", _SE(js_gfx_Shader_getSamplers), nullptr);
cls->defineFunction("destroy", _SE(js_gfx_Shader_destroy));
cls->defineFunction("getBuffers", _SE(js_gfx_Shader_getBuffers));
@@ -18974,12 +18974,12 @@ bool js_register_gfx_Texture(se::Object* obj) // NOLINT(readability-identifier-n
auto* cls = se::Class::create("Texture", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_Texture_constructor));
cls->defineProperty("info", _SE(js_gfx_Texture_getInfo), nullptr);
cls->defineProperty("hash", _SE(js_gfx_Texture_getHash), nullptr);
cls->defineProperty("format", _SE(js_gfx_Texture_getFormat), nullptr);
cls->defineProperty("height", _SE(js_gfx_Texture_getHeight), nullptr);
cls->defineProperty("width", _SE(js_gfx_Texture_getWidth), nullptr);
cls->defineProperty("viewInfo", _SE(js_gfx_Texture_getViewInfo), nullptr);
cls->defineProperty("width", _SE(js_gfx_Texture_getWidth), nullptr);
cls->defineProperty("height", _SE(js_gfx_Texture_getHeight), nullptr);
cls->defineProperty("format", _SE(js_gfx_Texture_getFormat), nullptr);
cls->defineProperty("size", _SE(js_gfx_Texture_getSize), nullptr);
cls->defineProperty("hash", _SE(js_gfx_Texture_getHash), nullptr);
cls->defineFunction("destroy", _SE(js_gfx_Texture_destroy));
cls->defineFunction("isTextureView", _SE(js_gfx_Texture_isTextureView));
cls->defineFunction("resize", _SE(js_gfx_Texture_resize));
@@ -19198,64 +19198,28 @@ static bool js_gfx_Swapchain_initialize(se::State& s) // NOLINT(readability-iden
}
SE_BIND_FUNC(js_gfx_Swapchain_initialize)
static bool js_gfx_Swapchain_isPreRotationEnabled(se::State& s) // NOLINT(readability-identifier-naming)
{
auto* cobj = SE_THIS_OBJECT<cc::gfx::Swapchain>(s);
SE_PRECONDITION2(cobj, false, "js_gfx_Swapchain_isPreRotationEnabled : Invalid Native Object");
const auto& args = s.args();
size_t argc = args.size();
CC_UNUSED bool ok = true;
if (argc == 0) {
bool result = cobj->isPreRotationEnabled();
ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/);
SE_PRECONDITION2(ok, false, "js_gfx_Swapchain_isPreRotationEnabled : Error processing arguments");
SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval());
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
return false;
}
SE_BIND_FUNC(js_gfx_Swapchain_isPreRotationEnabled)
static bool js_gfx_Swapchain_resize(se::State& s) // NOLINT(readability-identifier-naming)
{
CC_UNUSED bool ok = true;
auto* cobj = SE_THIS_OBJECT<cc::gfx::Swapchain>(s);
SE_PRECONDITION2( cobj, false, "js_gfx_Swapchain_resize : Invalid Native Object");
SE_PRECONDITION2(cobj, false, "js_gfx_Swapchain_resize : Invalid Native Object");
const auto& args = s.args();
size_t argc = args.size();
do {
if (argc == 2) {
HolderType<unsigned int, false> arg0 = {};
HolderType<unsigned int, false> arg1 = {};
CC_UNUSED bool ok = true;
if (argc == 3) {
HolderType<unsigned int, false> arg0 = {};
HolderType<unsigned int, false> arg1 = {};
HolderType<cc::gfx::SurfaceTransform, false> arg2 = {};
ok &= sevalue_to_native(args[0], &arg0, s.thisObject());
ok &= sevalue_to_native(args[1], &arg1, s.thisObject());
ok &= sevalue_to_native(args[2], &arg2, s.thisObject());
SE_PRECONDITION2(ok, false, "js_gfx_Swapchain_resize : Error processing arguments");
ok &= sevalue_to_native(args[0], &arg0, s.thisObject());
if (!ok) { ok = true; break; }
ok &= sevalue_to_native(args[1], &arg1, s.thisObject());
if (!ok) { ok = true; break; }
cobj->resize(arg0.value(), arg1.value());
return true;
}
} while(false);
CC_LOG_DEBUG(se::ScriptEngine::getInstance()->getCurrentStackTrace().c_str());
do {
if (argc == 3) {
HolderType<unsigned int, false> arg0 = {};
HolderType<unsigned int, false> arg1 = {};
HolderType<cc::gfx::SurfaceTransform, false> arg2 = {};
ok &= sevalue_to_native(args[0], &arg0, s.thisObject());
if (!ok) { ok = true; break; }
ok &= sevalue_to_native(args[1], &arg1, s.thisObject());
if (!ok) { ok = true; break; }
ok &= sevalue_to_native(args[2], &arg2, s.thisObject());
if (!ok) { ok = true; break; }
cobj->resize(arg0.value(), arg1.value(), arg2.value());
return true;
}
} while(false);
SE_REPORT_ERROR("wrong number of arguments: %d", (int)argc);
cobj->resize(arg0.value(), arg1.value(), arg2.value());
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3);
return false;
}
SE_BIND_FUNC(js_gfx_Swapchain_resize)
@@ -19290,17 +19254,16 @@ bool js_register_gfx_Swapchain(se::Object* obj) // NOLINT(readability-identifier
auto* cls = se::Class::create("Swapchain", obj, __jsb_cc_gfx_GFXObject_proto, _SE(js_gfx_Swapchain_constructor));
cls->defineProperty("width", _SE(js_gfx_Swapchain_getWidth), nullptr);
cls->defineProperty("surfaceTransform", _SE(js_gfx_Swapchain_getSurfaceTransform), nullptr);
cls->defineProperty("depthStencilTexture", _SE(js_gfx_Swapchain_getDepthStencilTexture), nullptr);
cls->defineProperty("colorTexture", _SE(js_gfx_Swapchain_getColorTexture), nullptr);
cls->defineProperty("height", _SE(js_gfx_Swapchain_getHeight), nullptr);
cls->defineProperty("surfaceTransform", _SE(js_gfx_Swapchain_getSurfaceTransform), nullptr);
cls->defineProperty("colorTexture", _SE(js_gfx_Swapchain_getColorTexture), nullptr);
cls->defineProperty("depthStencilTexture", _SE(js_gfx_Swapchain_getDepthStencilTexture), nullptr);
cls->defineFunction("createSurface", _SE(js_gfx_Swapchain_createSurface));
cls->defineFunction("destroy", _SE(js_gfx_Swapchain_destroy));
cls->defineFunction("destroySurface", _SE(js_gfx_Swapchain_destroySurface));
cls->defineFunction("getVSyncMode", _SE(js_gfx_Swapchain_getVSyncMode));
cls->defineFunction("getWindowHandle", _SE(js_gfx_Swapchain_getWindowHandle));
cls->defineFunction("initialize", _SE(js_gfx_Swapchain_initialize));
cls->defineFunction("isPreRotationEnabled", _SE(js_gfx_Swapchain_isPreRotationEnabled));
cls->defineFunction("resize", _SE(js_gfx_Swapchain_resize));
cls->defineFinalizeFunction(_SE(js_cc_gfx_Swapchain_finalize));
cls->install();
@@ -20265,17 +20228,17 @@ bool js_register_gfx_Device(se::Object* obj) // NOLINT(readability-identifier-na
{
auto* cls = se::Class::create("Device", obj, nullptr, nullptr);
cls->defineProperty("gfxAPI", _SE(js_gfx_Device_getGfxAPI), nullptr);
cls->defineProperty("deviceName", _SE(js_gfx_Device_getDeviceName), nullptr);
cls->defineProperty("memoryStatus", _SE(js_gfx_Device_getMemoryStatus), nullptr);
cls->defineProperty("queue", _SE(js_gfx_Device_getQueue), nullptr);
cls->defineProperty("commandBuffer", _SE(js_gfx_Device_getCommandBuffer), nullptr);
cls->defineProperty("renderer", _SE(js_gfx_Device_getRenderer), nullptr);
cls->defineProperty("vendor", _SE(js_gfx_Device_getVendor), nullptr);
cls->defineProperty("numDrawCalls", _SE(js_gfx_Device_getNumDrawCalls), nullptr);
cls->defineProperty("memoryStatus", _SE(js_gfx_Device_getMemoryStatus), nullptr);
cls->defineProperty("gfxAPI", _SE(js_gfx_Device_getGfxAPI), nullptr);
cls->defineProperty("capabilities", _SE(js_gfx_Device_getCapabilities), nullptr);
cls->defineProperty("numTris", _SE(js_gfx_Device_getNumTris), nullptr);
cls->defineProperty("queue", _SE(js_gfx_Device_getQueue), nullptr);
cls->defineProperty("renderer", _SE(js_gfx_Device_getRenderer), nullptr);
cls->defineProperty("commandBuffer", _SE(js_gfx_Device_getCommandBuffer), nullptr);
cls->defineProperty("numInstances", _SE(js_gfx_Device_getNumInstances), nullptr);
cls->defineProperty("numTris", _SE(js_gfx_Device_getNumTris), nullptr);
cls->defineProperty("capabilities", _SE(js_gfx_Device_getCapabilities), nullptr);
cls->defineFunction("acquire", _SE(js_gfx_Device_acquire));
cls->defineFunction("bindingMappingInfo", _SE(js_gfx_Device_bindingMappingInfo));
cls->defineFunction("createCommandBuffer", _SE(js_gfx_Device_createCommandBuffer));
@@ -20309,19 +20272,6 @@ bool js_register_gfx_Device(se::Object* obj) // NOLINT(readability-identifier-na
se::Object* __jsb_cc_gfx_DeviceManager_proto = nullptr;
se::Class* __jsb_cc_gfx_DeviceManager_class = nullptr;
static bool js_gfx_DeviceManager_destroy(se::State& s) // NOLINT(readability-identifier-naming)
{
const auto& args = s.args();
size_t argc = args.size();
if (argc == 0) {
cc::gfx::DeviceManager::destroy();
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
return false;
}
SE_BIND_FUNC(js_gfx_DeviceManager_destroy)
static bool js_gfx_DeviceManager_create(se::State& s) // NOLINT(readability-identifier-naming)
{
const auto& args = s.args();
@@ -20342,6 +20292,19 @@ static bool js_gfx_DeviceManager_create(se::State& s) // NOLINT(readability-iden
}
SE_BIND_FUNC(js_gfx_DeviceManager_create)
static bool js_gfx_DeviceManager_destroy(se::State& s) // NOLINT(readability-identifier-naming)
{
const auto& args = s.args();
size_t argc = args.size();
if (argc == 0) {
cc::gfx::DeviceManager::destroy();
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
return false;
}
SE_BIND_FUNC(js_gfx_DeviceManager_destroy)
static bool js_gfx_DeviceManager_addSurfaceEventListener(se::State& s) // NOLINT(readability-identifier-naming)
{
const auto& args = s.args();
@@ -20373,8 +20336,8 @@ bool js_register_gfx_DeviceManager(se::Object* obj) // NOLINT(readability-identi
{
auto* cls = se::Class::create("DeviceManager", obj, nullptr, nullptr);
cls->defineStaticFunction("destroy", _SE(js_gfx_DeviceManager_destroy));
cls->defineStaticFunction("create", _SE(js_gfx_DeviceManager_create));
cls->defineStaticFunction("destroy", _SE(js_gfx_DeviceManager_destroy));
cls->defineStaticFunction("addSurfaceEventListener", _SE(js_gfx_DeviceManager_addSurfaceEventListener));
cls->defineFinalizeFunction(_SE(js_cc_gfx_DeviceManager_finalize));
cls->install();
@@ -20398,81 +20361,81 @@ bool register_all_gfx(se::Object* obj)
}
se::Object* ns = nsVal.toObject();
js_register_gfx_Size(ns);
js_register_gfx_DeviceCaps(ns);
js_register_gfx_Offset(ns);
js_register_gfx_Rect(ns);
js_register_gfx_Extent(ns);
js_register_gfx_TextureSubresLayers(ns);
js_register_gfx_TextureSubresRange(ns);
js_register_gfx_TextureCopy(ns);
js_register_gfx_TextureBlit(ns);
js_register_gfx_BufferTextureCopy(ns);
js_register_gfx_Viewport(ns);
js_register_gfx_Color(ns);
js_register_gfx_BindingMappingInfo(ns);
js_register_gfx_SwapchainInfo(ns);
js_register_gfx_DeviceInfo(ns);
js_register_gfx_BufferInfo(ns);
js_register_gfx_BufferViewInfo(ns);
js_register_gfx_DrawInfo(ns);
js_register_gfx_DispatchInfo(ns);
js_register_gfx_IndirectBuffer(ns);
js_register_gfx_TextureInfo(ns);
js_register_gfx_TextureViewInfo(ns);
js_register_gfx_SamplerInfo(ns);
js_register_gfx_Uniform(ns);
js_register_gfx_UniformBlock(ns);
js_register_gfx_UniformSamplerTexture(ns);
js_register_gfx_UniformSampler(ns);
js_register_gfx_UniformTexture(ns);
js_register_gfx_UniformStorageImage(ns);
js_register_gfx_UniformStorageBuffer(ns);
js_register_gfx_UniformInputAttachment(ns);
js_register_gfx_ShaderStage(ns);
js_register_gfx_Attribute(ns);
js_register_gfx_ShaderInfo(ns);
js_register_gfx_InputAssemblerInfo(ns);
js_register_gfx_ColorAttachment(ns);
js_register_gfx_DepthStencilAttachment(ns);
js_register_gfx_SubpassInfo(ns);
js_register_gfx_SubpassDependency(ns);
js_register_gfx_RenderPassInfo(ns);
js_register_gfx_GlobalBarrierInfo(ns);
js_register_gfx_TextureBarrierInfo(ns);
js_register_gfx_FramebufferInfo(ns);
js_register_gfx_DescriptorSetLayoutBinding(ns);
js_register_gfx_DescriptorSetLayoutInfo(ns);
js_register_gfx_DescriptorSetInfo(ns);
js_register_gfx_PipelineLayoutInfo(ns);
js_register_gfx_InputState(ns);
js_register_gfx_RasterizerState(ns);
js_register_gfx_DepthStencilState(ns);
js_register_gfx_BlendTarget(ns);
js_register_gfx_BlendState(ns);
js_register_gfx_PipelineStateInfo(ns);
js_register_gfx_CommandBufferInfo(ns);
js_register_gfx_QueueInfo(ns);
js_register_gfx_MemoryStatus(ns);
js_register_gfx_GFXObject(ns);
js_register_gfx_Buffer(ns);
js_register_gfx_InputAssembler(ns);
js_register_gfx_CommandBuffer(ns);
js_register_gfx_DescriptorSet(ns);
js_register_gfx_DescriptorSetLayout(ns);
js_register_gfx_Framebuffer(ns);
js_register_gfx_PipelineLayout(ns);
js_register_gfx_PipelineState(ns);
js_register_gfx_Queue(ns);
js_register_gfx_RenderPass(ns);
js_register_gfx_Shader(ns);
js_register_gfx_Texture(ns);
js_register_gfx_Swapchain(ns);
js_register_gfx_GlobalBarrier(ns);
js_register_gfx_Sampler(ns);
js_register_gfx_TextureBarrier(ns);
js_register_gfx_Device(ns);
js_register_gfx_Texture(ns);
js_register_gfx_Uniform(ns);
js_register_gfx_DescriptorSet(ns);
js_register_gfx_BlendTarget(ns);
js_register_gfx_DispatchInfo(ns);
js_register_gfx_PipelineState(ns);
js_register_gfx_TextureBarrierInfo(ns);
js_register_gfx_PipelineLayout(ns);
js_register_gfx_Sampler(ns);
js_register_gfx_InputAssembler(ns);
js_register_gfx_RenderPass(ns);
js_register_gfx_BufferInfo(ns);
js_register_gfx_SamplerInfo(ns);
js_register_gfx_QueueInfo(ns);
js_register_gfx_UniformStorageBuffer(ns);
js_register_gfx_SubpassDependency(ns);
js_register_gfx_UniformSamplerTexture(ns);
js_register_gfx_BufferTextureCopy(ns);
js_register_gfx_PipelineLayoutInfo(ns);
js_register_gfx_InputAssemblerInfo(ns);
js_register_gfx_TextureBlit(ns);
js_register_gfx_TextureInfo(ns);
js_register_gfx_GlobalBarrierInfo(ns);
js_register_gfx_RenderPassInfo(ns);
js_register_gfx_Extent(ns);
js_register_gfx_Offset(ns);
js_register_gfx_CommandBuffer(ns);
js_register_gfx_Framebuffer(ns);
js_register_gfx_Viewport(ns);
js_register_gfx_TextureSubresLayers(ns);
js_register_gfx_BufferViewInfo(ns);
js_register_gfx_UniformInputAttachment(ns);
js_register_gfx_UniformSampler(ns);
js_register_gfx_ShaderInfo(ns);
js_register_gfx_PipelineStateInfo(ns);
js_register_gfx_Shader(ns);
js_register_gfx_BlendState(ns);
js_register_gfx_GlobalBarrier(ns);
js_register_gfx_DescriptorSetInfo(ns);
js_register_gfx_DescriptorSetLayoutInfo(ns);
js_register_gfx_DrawInfo(ns);
js_register_gfx_InputState(ns);
js_register_gfx_CommandBufferInfo(ns);
js_register_gfx_UniformStorageImage(ns);
js_register_gfx_UniformBlock(ns);
js_register_gfx_DepthStencilAttachment(ns);
js_register_gfx_TextureSubresRange(ns);
js_register_gfx_TextureViewInfo(ns);
js_register_gfx_Queue(ns);
js_register_gfx_ColorAttachment(ns);
js_register_gfx_RasterizerState(ns);
js_register_gfx_DeviceManager(ns);
js_register_gfx_Color(ns);
js_register_gfx_Attribute(ns);
js_register_gfx_MemoryStatus(ns);
js_register_gfx_DeviceInfo(ns);
js_register_gfx_Swapchain(ns);
js_register_gfx_DepthStencilState(ns);
js_register_gfx_BindingMappingInfo(ns);
js_register_gfx_FramebufferInfo(ns);
js_register_gfx_DeviceCaps(ns);
js_register_gfx_Rect(ns);
js_register_gfx_ShaderStage(ns);
js_register_gfx_DescriptorSetLayoutBinding(ns);
js_register_gfx_UniformTexture(ns);
js_register_gfx_DescriptorSetLayout(ns);
js_register_gfx_TextureCopy(ns);
js_register_gfx_IndirectBuffer(ns);
js_register_gfx_Size(ns);
return true;
}
+1 -2
View File
@@ -777,7 +777,6 @@ SE_DECLARE_FUNC(js_gfx_Swapchain_destroySurface);
SE_DECLARE_FUNC(js_gfx_Swapchain_getVSyncMode);
SE_DECLARE_FUNC(js_gfx_Swapchain_getWindowHandle);
SE_DECLARE_FUNC(js_gfx_Swapchain_initialize);
SE_DECLARE_FUNC(js_gfx_Swapchain_isPreRotationEnabled);
SE_DECLARE_FUNC(js_gfx_Swapchain_resize);
SE_DECLARE_FUNC(js_gfx_Swapchain_Swapchain);
@@ -849,7 +848,7 @@ bool js_register_cc_gfx_DeviceManager(se::Object* obj);
bool register_all_gfx(se::Object* obj);
JSB_REGISTER_OBJECT_TYPE(cc::gfx::DeviceManager);
SE_DECLARE_FUNC(js_gfx_DeviceManager_destroy);
SE_DECLARE_FUNC(js_gfx_DeviceManager_create);
SE_DECLARE_FUNC(js_gfx_DeviceManager_destroy);
SE_DECLARE_FUNC(js_gfx_DeviceManager_addSurfaceEventListener);
@@ -858,27 +858,6 @@ static bool js_pipeline_RenderPipeline_render(se::State& s) // NOLINT(readabilit
}
SE_BIND_FUNC(js_pipeline_RenderPipeline_render)
static bool js_pipeline_RenderPipeline_resize(se::State& s) // NOLINT(readability-identifier-naming)
{
auto* cobj = SE_THIS_OBJECT<cc::pipeline::RenderPipeline>(s);
SE_PRECONDITION2(cobj, false, "js_pipeline_RenderPipeline_resize : Invalid Native Object");
const auto& args = s.args();
size_t argc = args.size();
CC_UNUSED bool ok = true;
if (argc == 2) {
HolderType<unsigned int, false> arg0 = {};
HolderType<unsigned int, false> arg1 = {};
ok &= sevalue_to_native(args[0], &arg0, s.thisObject());
ok &= sevalue_to_native(args[1], &arg1, s.thisObject());
SE_PRECONDITION2(ok, false, "js_pipeline_RenderPipeline_resize : Error processing arguments");
cobj->resize(arg0.value(), arg1.value());
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2);
return false;
}
SE_BIND_FUNC(js_pipeline_RenderPipeline_resize)
static bool js_pipeline_RenderPipeline_setPipelineSharedSceneData(se::State& s) // NOLINT(readability-identifier-naming)
{
auto* cobj = SE_THIS_OBJECT<cc::pipeline::RenderPipeline>(s);
@@ -972,7 +951,6 @@ bool js_register_pipeline_RenderPipeline(se::Object* obj) // NOLINT(readability-
cls->defineFunction("getRenderstageByName", _SE(js_pipeline_RenderPipeline_getRenderstageByName));
cls->defineFunction("initialize", _SE(js_pipeline_RenderPipeline_initialize));
cls->defineFunction("render", _SE(js_pipeline_RenderPipeline_render));
cls->defineFunction("resize", _SE(js_pipeline_RenderPipeline_resize));
cls->defineFunction("setPipelineSharedSceneData", _SE(js_pipeline_RenderPipeline_setPipelineSharedSceneData));
cls->defineFunction("setProfiler", _SE(js_pipeline_RenderPipeline_setProfiler));
cls->defineFunction("setValue", _SE(js_pipeline_RenderPipeline_setValue));
@@ -2033,19 +2011,6 @@ static bool js_pipeline_InstancedBuffer_setDynamicOffset(se::State& s) // NOLINT
}
SE_BIND_FUNC(js_pipeline_InstancedBuffer_setDynamicOffset)
static bool js_pipeline_InstancedBuffer_destroyInstancedBuffer(se::State& s) // NOLINT(readability-identifier-naming)
{
const auto& args = s.args();
size_t argc = args.size();
if (argc == 0) {
cc::pipeline::InstancedBuffer::destroyInstancedBuffer();
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
return false;
}
SE_BIND_FUNC(js_pipeline_InstancedBuffer_destroyInstancedBuffer)
static bool js_pipeline_InstancedBuffer_get(se::State& s) // NOLINT(readability-identifier-naming)
{
CC_UNUSED bool ok = true;
@@ -2083,6 +2048,19 @@ static bool js_pipeline_InstancedBuffer_get(se::State& s) // NOLINT(readability-
}
SE_BIND_FUNC(js_pipeline_InstancedBuffer_get)
static bool js_pipeline_InstancedBuffer_destroyInstancedBuffer(se::State& s) // NOLINT(readability-identifier-naming)
{
const auto& args = s.args();
size_t argc = args.size();
if (argc == 0) {
cc::pipeline::InstancedBuffer::destroyInstancedBuffer();
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
return false;
}
SE_BIND_FUNC(js_pipeline_InstancedBuffer_destroyInstancedBuffer)
SE_DECLARE_FINALIZE_FUNC(js_cc_pipeline_InstancedBuffer_finalize)
static bool js_pipeline_InstancedBuffer_constructor(se::State& s) // NOLINT(readability-identifier-naming) constructor.c
@@ -2120,8 +2098,8 @@ bool js_register_pipeline_InstancedBuffer(se::Object* obj) // NOLINT(readability
cls->defineFunction("destroy", _SE(js_pipeline_InstancedBuffer_destroy));
cls->defineFunction("setDynamicOffset", _SE(js_pipeline_InstancedBuffer_setDynamicOffset));
cls->defineStaticFunction("destroyInstancedBuffer", _SE(js_pipeline_InstancedBuffer_destroyInstancedBuffer));
cls->defineStaticFunction("get", _SE(js_pipeline_InstancedBuffer_get));
cls->defineStaticFunction("destroyInstancedBuffer", _SE(js_pipeline_InstancedBuffer_destroyInstancedBuffer));
cls->defineFinalizeFunction(_SE(js_cc_pipeline_InstancedBuffer_finalize));
cls->install();
JSBClassType::registerClass<cc::pipeline::InstancedBuffer>(cls);
@@ -2135,6 +2113,25 @@ bool js_register_pipeline_InstancedBuffer(se::Object* obj) // NOLINT(readability
se::Object* __jsb_cc_pipeline_DeferredPipeline_proto = nullptr;
se::Class* __jsb_cc_pipeline_DeferredPipeline_class = nullptr;
static bool js_pipeline_DeferredPipeline_ensureEnoughSize(se::State& s) // NOLINT(readability-identifier-naming)
{
auto* cobj = SE_THIS_OBJECT<cc::pipeline::DeferredPipeline>(s);
SE_PRECONDITION2(cobj, false, "js_pipeline_DeferredPipeline_ensureEnoughSize : Invalid Native Object");
const auto& args = s.args();
size_t argc = args.size();
CC_UNUSED bool ok = true;
if (argc == 1) {
HolderType<std::vector<cc::scene::Camera *>, true> arg0 = {};
ok &= sevalue_to_native(args[0], &arg0, s.thisObject());
SE_PRECONDITION2(ok, false, "js_pipeline_DeferredPipeline_ensureEnoughSize : Error processing arguments");
cobj->ensureEnoughSize(arg0.value());
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
return false;
}
SE_BIND_FUNC(js_pipeline_DeferredPipeline_ensureEnoughSize)
static bool js_pipeline_DeferredPipeline_getClearcolor(se::State& s) // NOLINT(readability-identifier-naming)
{
auto* cobj = SE_THIS_OBJECT<cc::pipeline::DeferredPipeline>(s);
@@ -2176,25 +2173,6 @@ static bool js_pipeline_DeferredPipeline_getFrameGraph(se::State& s) // NOLINT(r
}
SE_BIND_FUNC(js_pipeline_DeferredPipeline_getFrameGraph)
static bool js_pipeline_DeferredPipeline_getFrameGraphCamera(se::State& s) // NOLINT(readability-identifier-naming)
{
auto* cobj = SE_THIS_OBJECT<cc::pipeline::DeferredPipeline>(s);
SE_PRECONDITION2(cobj, false, "js_pipeline_DeferredPipeline_getFrameGraphCamera : Invalid Native Object");
const auto& args = s.args();
size_t argc = args.size();
CC_UNUSED bool ok = true;
if (argc == 0) {
cc::scene::Camera* result = cobj->getFrameGraphCamera();
ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/);
SE_PRECONDITION2(ok, false, "js_pipeline_DeferredPipeline_getFrameGraphCamera : Error processing arguments");
SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval());
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
return false;
}
SE_BIND_FUNC(js_pipeline_DeferredPipeline_getFrameGraphCamera)
static bool js_pipeline_DeferredPipeline_getHeight(se::State& s) // NOLINT(readability-identifier-naming)
{
auto* cobj = SE_THIS_OBJECT<cc::pipeline::DeferredPipeline>(s);
@@ -2263,9 +2241,9 @@ bool js_register_pipeline_DeferredPipeline(se::Object* obj) // NOLINT(readabilit
{
auto* cls = se::Class::create("DeferredPipeline", obj, __jsb_cc_pipeline_RenderPipeline_proto, _SE(js_pipeline_DeferredPipeline_constructor));
cls->defineFunction("ensureEnoughSize", _SE(js_pipeline_DeferredPipeline_ensureEnoughSize));
cls->defineFunction("getClearcolor", _SE(js_pipeline_DeferredPipeline_getClearcolor));
cls->defineFunction("getFrameGraph", _SE(js_pipeline_DeferredPipeline_getFrameGraph));
cls->defineFunction("getFrameGraphCamera", _SE(js_pipeline_DeferredPipeline_getFrameGraphCamera));
cls->defineFunction("getHeight", _SE(js_pipeline_DeferredPipeline_getHeight));
cls->defineFunction("getWidth", _SE(js_pipeline_DeferredPipeline_getWidth));
cls->defineFinalizeFunction(_SE(js_cc_pipeline_DeferredPipeline_finalize));
@@ -2535,24 +2513,24 @@ bool register_all_pipeline(se::Object* obj)
se::Object* ns = nsVal.toObject();
js_register_pipeline_RenderQueueDesc(ns);
js_register_pipeline_RenderFlow(ns);
js_register_pipeline_RenderStage(ns);
js_register_pipeline_LightingStage(ns);
js_register_pipeline_RenderPipeline(ns);
js_register_pipeline_RenderStageInfo(ns);
js_register_pipeline_ForwardPipeline(ns);
js_register_pipeline_GbufferStage(ns);
js_register_pipeline_RenderPipelineInfo(ns);
js_register_pipeline_ForwardStage(ns);
js_register_pipeline_ShadowStage(ns);
js_register_pipeline_GlobalDSManager(ns);
js_register_pipeline_RenderPipelineInfo(ns);
js_register_pipeline_RenderPipeline(ns);
js_register_pipeline_ForwardPipeline(ns);
js_register_pipeline_RenderFlowInfo(ns);
js_register_pipeline_PostprocessStage(ns);
js_register_pipeline_RenderFlow(ns);
js_register_pipeline_ForwardFlow(ns);
js_register_pipeline_RenderStageInfo(ns);
js_register_pipeline_RenderStage(ns);
js_register_pipeline_ForwardStage(ns);
js_register_pipeline_ShadowFlow(ns);
js_register_pipeline_ShadowStage(ns);
js_register_pipeline_InstancedBuffer(ns);
js_register_pipeline_DeferredPipeline(ns);
js_register_pipeline_MainFlow(ns);
js_register_pipeline_ShadowFlow(ns);
js_register_pipeline_GbufferStage(ns);
js_register_pipeline_LightingStage(ns);
js_register_pipeline_PostprocessStage(ns);
return true;
}
@@ -75,7 +75,6 @@ SE_DECLARE_FUNC(js_pipeline_RenderPipeline_getProfiler);
SE_DECLARE_FUNC(js_pipeline_RenderPipeline_getRenderstageByName);
SE_DECLARE_FUNC(js_pipeline_RenderPipeline_initialize);
SE_DECLARE_FUNC(js_pipeline_RenderPipeline_render);
SE_DECLARE_FUNC(js_pipeline_RenderPipeline_resize);
SE_DECLARE_FUNC(js_pipeline_RenderPipeline_setPipelineSharedSceneData);
SE_DECLARE_FUNC(js_pipeline_RenderPipeline_setProfiler);
SE_DECLARE_FUNC(js_pipeline_RenderPipeline_setValue);
@@ -185,8 +184,8 @@ bool register_all_pipeline(se::Object* obj);
JSB_REGISTER_OBJECT_TYPE(cc::pipeline::InstancedBuffer);
SE_DECLARE_FUNC(js_pipeline_InstancedBuffer_destroy);
SE_DECLARE_FUNC(js_pipeline_InstancedBuffer_setDynamicOffset);
SE_DECLARE_FUNC(js_pipeline_InstancedBuffer_destroyInstancedBuffer);
SE_DECLARE_FUNC(js_pipeline_InstancedBuffer_get);
SE_DECLARE_FUNC(js_pipeline_InstancedBuffer_destroyInstancedBuffer);
SE_DECLARE_FUNC(js_pipeline_InstancedBuffer_InstancedBuffer);
extern se::Object* __jsb_cc_pipeline_DeferredPipeline_proto;
@@ -196,9 +195,9 @@ bool js_register_cc_pipeline_DeferredPipeline(se::Object* obj);
bool register_all_pipeline(se::Object* obj);
JSB_REGISTER_OBJECT_TYPE(cc::pipeline::DeferredPipeline);
SE_DECLARE_FUNC(js_pipeline_DeferredPipeline_ensureEnoughSize);
SE_DECLARE_FUNC(js_pipeline_DeferredPipeline_getClearcolor);
SE_DECLARE_FUNC(js_pipeline_DeferredPipeline_getFrameGraph);
SE_DECLARE_FUNC(js_pipeline_DeferredPipeline_getFrameGraphCamera);
SE_DECLARE_FUNC(js_pipeline_DeferredPipeline_getHeight);
SE_DECLARE_FUNC(js_pipeline_DeferredPipeline_getWidth);
SE_DECLARE_FUNC(js_pipeline_DeferredPipeline_DeferredPipeline);
+1 -1
View File
@@ -55,7 +55,7 @@ const Device::MotionValue &Device::getDeviceMotionValue() {
}
Device::Orientation Device::getDeviceOrientation() {
return Device::Orientation::LANDSCAPE_RIGHT;
return Device::Orientation::PORTRAIT;
}
std::string Device::getDeviceModel() {
@@ -39,7 +39,7 @@ public:
Executable &operator=(const Executable &) = delete;
Executable &operator=(Executable &&) noexcept = delete;
virtual void execute(const DevicePassResourceTable &resourceTable) const noexcept = 0;
virtual void execute(const DevicePassResourceTable &resourceTable) noexcept = 0;
};
template <typename Data, typename ExecuteMethodType>
@@ -50,7 +50,7 @@ public:
explicit CallbackPass(ExecuteMethod &execute) noexcept;
explicit CallbackPass(ExecuteMethod &&execute) noexcept;
void execute(const DevicePassResourceTable &resourceTable) const noexcept override;
void execute(const DevicePassResourceTable &resourceTable) noexcept override;
inline const Data &getData() const noexcept { return _data; }
inline Data & getData() noexcept { return _data; }
@@ -74,7 +74,7 @@ CallbackPass<Data, ExecuteMethod>::CallbackPass(ExecuteMethod &&execute) noexcep
}
template <typename Data, typename ExecuteMethod>
void CallbackPass<Data, ExecuteMethod>::execute(const DevicePassResourceTable &resourceTable) const noexcept {
void CallbackPass<Data, ExecuteMethod>::execute(const DevicePassResourceTable &resourceTable) noexcept {
_execute(_data, resourceTable);
}
@@ -35,7 +35,8 @@ namespace gfx {
SwapchainAgent::SwapchainAgent(Swapchain *actor)
: Agent<Swapchain>(actor) {
_typedID = actor->getTypedID();
_typedID = actor->getTypedID();
_preRotationEnabled = static_cast<SwapchainAgent *>(actor)->_preRotationEnabled;
}
SwapchainAgent::~SwapchainAgent() {
@@ -36,13 +36,6 @@ public:
explicit SwapchainAgent(Swapchain *actor);
~SwapchainAgent() override;
bool isPreRotationEnabled() override { return _actor->isPreRotationEnabled(); }
// TO BE REMOVED
SurfaceTransform getSurfaceTransform() const override { return _actor->getSurfaceTransform(); }
uint32_t getWidth() const override { return _actor->getWidth(); }
uint32_t getHeight() const override { return _actor->getHeight(); }
protected:
void doInit(const SwapchainInfo &info) override;
void doDestroy() override;
+10 -10
View File
@@ -52,18 +52,18 @@ void Swapchain::destroy() {
}
void Swapchain::resize(uint32_t width, uint32_t height, SurfaceTransform transform) {
if (width != _colorTexture->getWidth() || height != _colorTexture->getHeight() || transform != _transform) {
doResize(width, height, transform);
// if pre-rotation is enabled, width & height should always be measured in un-oriented space
uint32_t newWidth = width;
uint32_t newHeight = height;
if (_preRotationEnabled && toNumber(transform) & 1) std::swap(newWidth, newHeight);
// if (isPreRotationEnabled()) {
// if (toNumber(transform) % 2) {
// std::swap(width, height);
// }
// _transform = transform;
// }
if (newWidth != _colorTexture->getWidth() || newHeight != _colorTexture->getHeight() ||
(_preRotationEnabled && transform != _transform)) {
doResize(width, height, transform); // pass oriented size
// _colorTexture->_info.width = _depthStencilTexture->_info.width = width;
// _colorTexture->_info.height = _depthStencilTexture->_info.height = height;
_colorTexture->_info.width = _depthStencilTexture->_info.width = newWidth;
_colorTexture->_info.height = _depthStencilTexture->_info.height = newHeight;
if (_preRotationEnabled) _transform = transform; // only update transform when using pre-rotation
}
}
+15 -9
View File
@@ -37,9 +37,20 @@ public:
~Swapchain() override;
void initialize(const SwapchainInfo &info);
void resize(uint32_t width, uint32_t height, SurfaceTransform transform);
void destroy();
/**
* Resize the swapchain with the given metric.
* Note that you should invoke this function iff when there is actual
* size or orientation changes, with the up-to-date information about
* the underlying surface.
*
* @param width The width of the surface in oriented screen space
* @param height The height of the surface in oriented screen space
* @param transform The orientation of the surface
*/
void resize(uint32_t width, uint32_t height, SurfaceTransform transform);
inline void destroySurface();
inline void createSurface(void *windowHandle);
@@ -49,14 +60,9 @@ public:
inline Texture *getColorTexture() const { return _colorTexture; }
inline Texture *getDepthStencilTexture() const { return _depthStencilTexture; }
virtual bool isPreRotationEnabled() { return _preRotationEnabled; }
// TO BE REMOVED
inline void resize(uint32_t width, uint32_t height) { resize(width, height, SurfaceTransform::IDENTITY); }
// TO BE INLINED
virtual SurfaceTransform getSurfaceTransform() const { return _transform; }
virtual uint32_t getWidth() const { return _colorTexture->getWidth(); }
virtual uint32_t getHeight() const { return _colorTexture->getHeight(); }
inline SurfaceTransform getSurfaceTransform() const { return _transform; }
inline uint32_t getWidth() const { return _colorTexture->getWidth(); }
inline uint32_t getHeight() const { return _colorTexture->getHeight(); }
protected:
virtual void doInit(const SwapchainInfo &info) = 0;
@@ -1415,7 +1415,7 @@ void GLES2GPUFramebuffer::GLFramebuffer::destroy(GLES2GPUStateCache *cache, GLES
}
void cmdFuncGLES2DestroyFramebuffer(GLES2Device *device, GLES2GPUFramebuffer *gpuFBO) {
auto *cache = device->stateCache();
auto *cache = device->stateCache();
auto *framebufferCacheMap = device->framebufferCacheMap();
for (auto &instance : gpuFBO->instances) {
@@ -2630,13 +2630,14 @@ void cmdFuncGLES2CopyBuffersToTexture(GLES2Device *device, const uint8_t *const
CC_GLES2_API void cmdFuncGLES2CopyTextureToBuffers(GLES2Device *device, GLES2GPUTexture *gpuTexture, uint8_t *const *buffers, const BufferTextureCopy *regions, uint count) {
GLuint framebuffer = device->framebufferCacheMap()->getFramebufferFromTexture(gpuTexture);
auto glFormat = mapGLFormat(gpuTexture->format);
auto glType = formatToGLType(gpuTexture->format);
auto glFormat = gpuTexture->glFormat;
auto glType = gpuTexture->glType;
if (device->stateCache()->glFramebuffer != framebuffer) {
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, framebuffer));
device->stateCache()->glFramebuffer = framebuffer;
}
for (uint32_t i = 0; i < count; ++i) {
auto region = regions[i];
uint8_t *copyDst = buffers[i];
@@ -111,16 +111,19 @@ void GLES2Swapchain::doDestroy() {
}
void GLES2Swapchain::doResize(uint32_t width, uint32_t height, SurfaceTransform /*transform*/) {
doDestroySurface();
_colorTexture->resize(width, height);
_depthStencilTexture->resize(width, height);
doCreateSurface(_windowHandle);
}
void GLES2Swapchain::doDestroySurface() {
if (_gpuSwapchain->eglSurface != EGL_NO_SURFACE) {
const auto* context = GLES2Device::getInstance()->context();
auto* context = GLES2Device::getInstance()->context();
eglDestroySurface(context->eglDisplay, _gpuSwapchain->eglSurface);
EGL_CHECK(eglMakeCurrent(context->eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
_gpuSwapchain->eglSurface = EGL_NO_SURFACE;
context->bindContext(false);
}
}
@@ -134,14 +137,13 @@ void GLES2Swapchain::doCreateSurface(void* windowHandle) {
return;
}
// Device's size will be updated after recreate window (in resize event) and is incorrect for now.
auto width = static_cast<int>(_colorTexture->getWidth());
auto height = static_cast<int>(_colorTexture->getHeight());
#if CC_PLATFORM == CC_PLATFORM_ANDROID
int32_t width = ANativeWindow_getWidth(window);
int32_t height = ANativeWindow_getHeight(window);
ANativeWindow_setBuffersGeometry(window, width, height, nFmt);
#elif CC_PLATFORM == CC_PLATFORM_OHOS
int32_t width = NativeLayerHandle(window, NativeLayerOps::GET_WIDTH);
int32_t height = NativeLayerHandle(window, NativeLayerOps::GET_HEIGHT);
NativeLayerHandle(window, NativeLayerOps::SET_WIDTH_AND_HEIGHT, width, height);
NativeLayerHandle(window, SET_FORMAT, nFmt);
#endif
EGL_CHECK(_gpuSwapchain->eglSurface = eglCreateWindowSurface(context->eglDisplay, context->eglConfig, window, nullptr));
@@ -149,6 +151,8 @@ void GLES2Swapchain::doCreateSurface(void* windowHandle) {
CC_LOG_ERROR("Recreate window surface failed.");
return;
}
context->makeCurrent(_gpuSwapchain, _gpuSwapchain);
}
} // namespace gfx
@@ -2951,8 +2951,9 @@ void cmdFuncGLES3CopyBuffersToTexture(GLES3Device *device, const uint8_t *const
}
CC_GLES3_API void cmdFuncGLES3CopyTextureToBuffers(GLES3Device *device, GLES3GPUTexture *gpuTexture, uint8_t *const *buffers, const BufferTextureCopy *regions, uint count) {
auto glFormat = mapGLFormat(gpuTexture->format);
auto glType = formatToGLType(gpuTexture->format);
auto glFormat = gpuTexture->glFormat;
auto glType = gpuTexture->glType;
for (uint32_t i = 0; i < count; ++i) {
auto region = regions[i];
uint8_t *copyDst = buffers[i];
@@ -111,16 +111,20 @@ void GLES3Swapchain::doDestroy() {
}
void GLES3Swapchain::doResize(uint32_t width, uint32_t height, SurfaceTransform /*transform*/) {
doDestroySurface();
_colorTexture->resize(width, height);
_depthStencilTexture->resize(width, height);
doCreateSurface(_windowHandle);
}
void GLES3Swapchain::doDestroySurface() {
if (_gpuSwapchain->eglSurface != EGL_NO_SURFACE) {
const auto* context = GLES3Device::getInstance()->context();
auto* context = GLES3Device::getInstance()->context();
eglDestroySurface(context->eglDisplay, _gpuSwapchain->eglSurface);
EGL_CHECK(eglMakeCurrent(context->eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
_gpuSwapchain->eglSurface = EGL_NO_SURFACE;
context->bindContext(false);
}
}
@@ -134,14 +138,13 @@ void GLES3Swapchain::doCreateSurface(void* windowHandle) {
return;
}
// Device's size will be updated after recreate window (in resize event) and is incorrect for now.
auto width = static_cast<int>(_colorTexture->getWidth());
auto height = static_cast<int>(_colorTexture->getHeight());
#if CC_PLATFORM == CC_PLATFORM_ANDROID
int32_t width = ANativeWindow_getWidth(window);
int32_t height = ANativeWindow_getHeight(window);
ANativeWindow_setBuffersGeometry(window, width, height, nFmt);
#elif CC_PLATFORM == CC_PLATFORM_OHOS
int32_t width = NativeLayerHandle(window, NativeLayerOps::GET_WIDTH);
int32_t height = NativeLayerHandle(window, NativeLayerOps::GET_HEIGHT);
NativeLayerHandle(window, NativeLayerOps::SET_WIDTH_AND_HEIGHT, width, height);
NativeLayerHandle(window, SET_FORMAT, nFmt);
#endif
EGL_CHECK(_gpuSwapchain->eglSurface = eglCreateWindowSurface(context->eglDisplay, context->eglConfig, window, nullptr));
@@ -149,6 +152,8 @@ void GLES3Swapchain::doCreateSurface(void* windowHandle) {
CC_LOG_ERROR("Recreate window surface failed.");
return;
}
context->makeCurrent(_gpuSwapchain, _gpuSwapchain);
}
} // namespace gfx
@@ -37,6 +37,7 @@ namespace gfx {
SwapchainValidator::SwapchainValidator(Swapchain *actor)
: Agent<Swapchain>(actor) {
_typedID = actor->getTypedID();
_preRotationEnabled = static_cast<SwapchainValidator *>(actor)->_preRotationEnabled;
}
SwapchainValidator::~SwapchainValidator() {
@@ -37,13 +37,6 @@ public:
explicit SwapchainValidator(Swapchain *actor);
~SwapchainValidator() override;
bool isPreRotationEnabled() override { return _actor->isPreRotationEnabled(); }
// TO BE REMOVED
SurfaceTransform getSurfaceTransform() const override { return _actor->getSurfaceTransform(); }
uint32_t getWidth() const override { return _actor->getWidth(); }
uint32_t getHeight() const override { return _actor->getHeight(); }
protected:
void doInit(const SwapchainInfo &info) override;
void doDestroy() override;
@@ -25,10 +25,10 @@
#include "VKStd.h"
#include "gfx-base/SPIRVUtils.h"
#include "VKCommands.h"
#include "VKDevice.h"
#include "VKGPUObjects.h"
#include "gfx-base/SPIRVUtils.h"
namespace cc {
namespace gfx {
@@ -1225,7 +1225,10 @@ void cmdFuncCCVKCopyBuffersToTexture(CCVKDevice *device, const uint8_t *const *b
device->gpuBarrierManager()->checkIn(gpuTexture);
}
CC_VULKAN_API void cmdFuncCCVKCopyTextureToBuffers(CCVKDevice * /*device*/, CCVKGPUTexture *srcTexture, CCVKGPUBuffer *destBuffer, const BufferTextureCopy *regions, uint count, const CCVKGPUCommandBuffer *gpuCommandBuffer) {
CC_VULKAN_API void cmdFuncCCVKCopyTextureToBuffers(CCVKDevice * device, CCVKGPUTexture *srcTexture, CCVKGPUBuffer *destBuffer,
const BufferTextureCopy *regions, uint count, const CCVKGPUCommandBuffer *gpuCommandBuffer) {
vector<ThsvsAccessType> &curTypes = srcTexture->currentAccessTypes;
ThsvsImageBarrier barrier{};
barrier.image = srcTexture->vkImage;
barrier.discardContents = false;
@@ -1234,8 +1237,8 @@ CC_VULKAN_API void cmdFuncCCVKCopyTextureToBuffers(CCVKDevice * /*device*/, CCVK
barrier.subresourceRange.levelCount = VK_REMAINING_MIP_LEVELS;
barrier.subresourceRange.layerCount = VK_REMAINING_ARRAY_LAYERS;
barrier.subresourceRange.aspectMask = srcTexture->aspectMask;
barrier.prevAccessCount = utils::toUint(srcTexture->currentAccessTypes.size());
barrier.pPrevAccesses = srcTexture->currentAccessTypes.data();
barrier.prevAccessCount = utils::toUint(curTypes.size());
barrier.pPrevAccesses = curTypes.data();
barrier.nextAccessCount = 1;
barrier.pNextAccesses = &THSVS_ACCESS_TYPES[static_cast<uint>(AccessType::TRANSFER_READ)];
@@ -1264,11 +1267,9 @@ CC_VULKAN_API void cmdFuncCCVKCopyTextureToBuffers(CCVKDevice * /*device*/, CCVK
vkCmdCopyImageToBuffer(gpuCommandBuffer->vkCommandBuffer, srcTexture->vkImage, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
destBuffer->vkBuffer, utils::toUint(stagingRegions.size()), stagingRegions.data());
if (srcTexture->transferAccess != THSVS_ACCESS_TRANSFER_READ) {
std::swap(barrier.prevAccessCount, barrier.nextAccessCount);
std::swap(barrier.pPrevAccesses, barrier.pNextAccesses);
cmdFuncCCVKImageMemoryBarrier(gpuCommandBuffer, barrier);
}
curTypes.assign({THSVS_ACCESS_TRANSFER_READ});
srcTexture->transferAccess = THSVS_ACCESS_TRANSFER_READ;
device->gpuBarrierManager()->checkIn(srcTexture);
}
void cmdFuncCCVKDestroyRenderPass(CCVKGPUDevice *gpuDevice, CCVKGPURenderPass *gpuRenderPass) {
@@ -755,17 +755,21 @@ void CCVKDevice::copyTextureToBuffers(Texture *srcTexture, uint8_t *const *buffe
regionOffsetSizes[i] = {totalSize, regionSize};
totalSize += regionSize;
}
CCVKGPUBuffer stagingBuffer;
stagingBuffer.size = totalSize;
uint texelSize = GFX_FORMAT_INFOS[toNumber(format)].size;
gpuStagingBufferPool()->alloc(&stagingBuffer, texelSize);
// make sure the src texture is up-to-date
waitAllFences();
_gpuTransportHub->checkIn(
[&](CCVKGPUCommandBuffer *cmdBuffer) {
cmdFuncCCVKCopyTextureToBuffers(this, static_cast<CCVKTexture *>(srcTexture)->gpuTexture(), &stagingBuffer, regions, count, cmdBuffer);
},
true);
for (uint i = 0; i < count; ++i) {
uint regionOffset = 0;
uint regionSize = 0;
@@ -46,7 +46,7 @@ CCVKSwapchain::~CCVKSwapchain() {
destroy();
}
void CCVKSwapchain::doInit(const SwapchainInfo & /*info*/) {
void CCVKSwapchain::doInit(const SwapchainInfo &info) {
auto * gpuDevice = CCVKDevice::getInstance()->gpuDevice();
const auto *gpuContext = CCVKDevice::getInstance()->gpuContext();
_gpuSwapchain = CC_NEW(CCVKGPUSwapchain);
@@ -205,8 +205,8 @@ void CCVKSwapchain::doInit(const SwapchainInfo & /*info*/) {
SwapchainTextureInfo textureInfo;
textureInfo.swapchain = this;
textureInfo.format = colorFmt;
textureInfo.width = 1;
textureInfo.height = 1;
textureInfo.width = info.width;
textureInfo.height = info.height;
initTexture(textureInfo, _colorTexture);
textureInfo.format = depthStencilFmt;
@@ -237,30 +237,38 @@ void CCVKSwapchain::doDestroy() {
CC_SAFE_DELETE(_gpuSwapchain)
}
void CCVKSwapchain::doResize(uint32_t /*width*/, uint32_t /*height*/, SurfaceTransform /*transform*/) {
checkSwapchainStatus();
void CCVKSwapchain::doResize(uint32_t width, uint32_t height, SurfaceTransform transform) {
checkSwapchainStatus(width, height);
// If these assertions are hit that almost always means something is wrong with the
// resize event dispatch logic instead of the resize implementation executed above.
if (ENABLE_PRE_ROTATION && toNumber(transform) & 1) std::swap(width, height);
CCASSERT(getWidth() == width && getHeight() == height, "Wrong input size");
CCASSERT(_transform == transform, "Wrong surface transformation");
}
bool CCVKSwapchain::checkSwapchainStatus() {
bool CCVKSwapchain::checkSwapchainStatus(uint32_t width, uint32_t height) {
auto * gpuDevice = CCVKDevice::getInstance()->gpuDevice();
const auto *gpuContext = CCVKDevice::getInstance()->gpuContext();
VkSurfaceCapabilitiesKHR surfaceCapabilities;
VK_CHECK(vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpuContext->physicalDevice, _gpuSwapchain->vkSurface, &surfaceCapabilities));
uint newWidth = surfaceCapabilities.currentExtent.width;
uint newHeight = surfaceCapabilities.currentExtent.height;
// surfaceCapabilities.currentExtent seems to remain the same
// during any size/orientation change events on android devices
// so we prefer the system input (oriented size) here
uint newWidth = width ? width : surfaceCapabilities.currentExtent.width;
uint newHeight = height ? height : surfaceCapabilities.currentExtent.height;
VkSurfaceTransformFlagBitsKHR preTransform = surfaceCapabilities.currentTransform;
if (!ENABLE_PRE_ROTATION) {
if (ENABLE_PRE_ROTATION) {
if (preTransform & TRANSFORMS_THAT_REQUIRE_FLIPPING) {
std::swap(newWidth, newHeight);
}
} else {
preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
}
if (preTransform & TRANSFORMS_THAT_REQUIRE_FLIPPING) {
newHeight = surfaceCapabilities.currentExtent.width;
newWidth = surfaceCapabilities.currentExtent.height;
}
if (_gpuSwapchain->createInfo.preTransform == preTransform &&
_gpuSwapchain->createInfo.imageExtent.width == newWidth &&
_gpuSwapchain->createInfo.imageExtent.height == newHeight && _gpuSwapchain->lastPresentResult == VK_SUCCESS) {
@@ -306,8 +314,8 @@ bool CCVKSwapchain::checkSwapchainStatus() {
CCASSERT(imageCount == _gpuSwapchain->createInfo.minImageCount, "swapchain image count assumption is broken");
// should skip size check, since the old swapchain has already been destroyed
static_cast<CCVKTexture *>(_colorTexture)->_info.width = 0;
static_cast<CCVKTexture *>(_depthStencilTexture)->_info.width = 0;
static_cast<CCVKTexture *>(_colorTexture)->_info.width = 1;
static_cast<CCVKTexture *>(_depthStencilTexture)->_info.width = 1;
_colorTexture->resize(newWidth, newHeight);
_depthStencilTexture->resize(newWidth, newHeight);
@@ -46,7 +46,7 @@ public:
inline CCVKGPUSwapchain *gpuSwapchain() { return _gpuSwapchain; }
bool checkSwapchainStatus();
bool checkSwapchainStatus(uint32_t width = 0, uint32_t height = 0);
protected:
void doInit(const SwapchainInfo &info) override;
@@ -56,7 +56,6 @@ protected:
void doCreateSurface(void *windowHandle) override;
void createVkSurface();
void destroySwapchain(const CCVKGPUDevice *gpuDevice);
CCVKGPUSwapchain *_gpuSwapchain = nullptr;
@@ -61,7 +61,6 @@ public:
virtual void destroy();
virtual bool initialize(const RenderPipelineInfo &info);
virtual void render(const vector<scene::Camera *> &cameras);
virtual void resize(uint width, uint height){};
void setPipelineSharedSceneData(scene::PipelineSharedSceneData *data);
@@ -106,26 +106,19 @@ void DeferredPipeline::render(const vector<scene::Camera *> &cameras) {
_commandBuffers[0]->begin();
_pipelineUBO->updateGlobalUBO(cameras[0]);
_pipelineUBO->updateMultiCameraUBO(cameras);
ensureEnoughSize(cameras);
for (auto *camera : cameras) {
_fg.reset();
sceneCulling(this, camera);
_frameGraphCamera = camera;
_fg.reset();
for (auto *const flow : _flows) {
flow->render(camera);
}
_fg.compile();
/* *
static bool exported = false;
if (!exported) {
_fg.exportGraphViz("fg_vis.dot");
exported = true;
}
// */
// _fg.exportGraphViz("fg_vis.dot");
_fg.execute();
_pipelineUBO->incCameraUBOOffset();
}
@@ -293,12 +286,11 @@ bool DeferredPipeline::activeRenderer(gfx::Swapchain *swapchain) {
return true;
}
void DeferredPipeline::resize(uint width, uint height) {
if (_width == width && _height == height) {
return;
void DeferredPipeline::ensureEnoughSize(const vector<scene::Camera *> &cameras) {
for (auto *camera : cameras) {
_width = std::max(camera->window->getWidth(), _width);
_height = std::max(camera->window->getHeight(), _height);
}
_width = width;
_height = height;
}
void DeferredPipeline::destroy() {
@@ -33,6 +33,7 @@
#include "gfx-base/GFXBuffer.h"
#include "gfx-base/GFXInputAssembler.h"
#include "pipeline/RenderPipeline.h"
#include "scene/RenderWindow.h"
namespace cc {
namespace pipeline {
@@ -66,7 +67,6 @@ public:
void destroy() override;
bool activate(gfx::Swapchain *swapchain) override;
void render(const vector<scene::Camera *> &cameras) override;
void resize(uint width, uint height) override;
inline gfx::Buffer * getLightsUBO() const { return _lightsUBO; }
inline const LightList & getValidLights() const { return _validLights; }
@@ -76,12 +76,12 @@ public:
gfx::Rect getRenderArea(scene::Camera *camera, bool onScreen);
void updateQuadVertexData(const gfx::Rect &renderArea, gfx::Buffer *buffer);
void genQuadVertexData(const gfx::Rect &renderArea, float *data);
void ensureEnoughSize(const vector<scene::Camera *> &cameras);
framegraph::FrameGraph &getFrameGraph() { return _fg; }
gfx::Color getClearcolor(scene::Camera *camera);
uint getWidth() const { return _width; }
uint getHeight() const { return _height; }
scene::Camera * getFrameGraphCamera() const { return _frameGraphCamera; }
gfx::InputAssembler * getIAByRenderArea(const gfx::Rect &rect);
private:
@@ -105,7 +105,6 @@ private:
uint _height = 0;
framegraph::FrameGraph _fg;
scene::Camera * _frameGraphCamera = nullptr;
public:
static constexpr uint GBUFFER_COUNT = 4;
@@ -378,7 +378,7 @@ void LightingStage::fgLightingPass(scene::Camera *camera) {
builder.setViewport(viewport, renderArea);
};
auto lightingExec = [this](RenderData const &data, const framegraph::DevicePassResourceTable &table) {
auto lightingExec = [this, camera](RenderData const &data, const framegraph::DevicePassResourceTable &table) {
auto * pipeline = static_cast<DeferredPipeline *>(_pipeline);
auto *const sceneData = pipeline->getPipelineSceneData();
@@ -389,7 +389,7 @@ void LightingStage::fgLightingPass(scene::Camera *camera) {
uint const globalOffsets[] = {pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()};
cmdBuff->bindDescriptorSet(globalSet, pipeline->getDescriptorSet(), static_cast<uint>(std::size(globalOffsets)), globalOffsets);
// get PSO and draw quad
auto rendeArea = pipeline->getRenderArea(pipeline->getFrameGraphCamera(), false);
auto rendeArea = pipeline->getRenderArea(camera, false);
scene::Pass * pass = sceneData->getSharedData()->deferredLightPass;
gfx::Shader * shader = sceneData->getSharedData()->deferredLightPassShader;
@@ -172,7 +172,7 @@ void PostprocessStage::render(scene::Camera *camera) {
builder.setViewport(viewport, renderArea);
};
auto postExec = [this](RenderData const &data, const framegraph::DevicePassResourceTable &table) {
auto postExec = [this, camera](RenderData const &data, const framegraph::DevicePassResourceTable &table) {
auto * pipeline = static_cast<DeferredPipeline *>(_pipeline);
gfx::RenderPass *renderPass = table.getRenderPass();
@@ -190,7 +190,6 @@ void PostprocessStage::render(scene::Camera *camera) {
gfx::Shader *sd = sceneData->getSharedData()->deferredPostPassShader;
// get pso and draw quad
auto * camera = pipeline->getFrameGraphCamera();
auto rendeArea = pipeline->getRenderArea(camera, camera->window->swapchain);
gfx::InputAssembler *ia = pipeline->getIAByRenderArea(rendeArea);
gfx::PipelineState * pso = PipelineStateManager::getOrCreatePipelineState(pv, sd, ia, renderPass);
@@ -212,7 +211,7 @@ void PostprocessStage::render(scene::Camera *camera) {
cmdBuff->draw(ia);
}
_uiPhase->render(pipeline->getFrameGraphCamera(), renderPass);
_uiPhase->render(camera, renderPass);
};
// add pass
@@ -118,6 +118,7 @@ void ForwardPipeline::render(const vector<scene::Camera *> &cameras) {
_commandBuffers[0]->begin();
_pipelineUBO->updateGlobalUBO(cameras[0]);
_pipelineUBO->updateMultiCameraUBO(cameras);
for (auto *camera : cameras) {
sceneCulling(this, camera);
for (auto *const flow : _flows) {
@@ -125,6 +126,7 @@ void ForwardPipeline::render(const vector<scene::Camera *> &cameras) {
}
_pipelineUBO->incCameraUBOOffset();
}
_commandBuffers[0]->end();
_device->flushCommands(_commandBuffers);
_device->getQueue()->submit(_commandBuffers);