mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
fix manual js bindings (#3914)
This commit is contained in:
@@ -67,7 +67,7 @@ bool js_gfx_Device_copyBuffersToTexture(se::State &s) { // NOLINT(readability-id
|
||||
assert(false);
|
||||
}
|
||||
} else {
|
||||
ptr = reinterpret_cast<uint8_t *>(value.asPtr());
|
||||
ptr = reinterpret_cast<uint8_t *>(value.asPtr()); // NOLINT(performance-no-int-to-ptr) script engine bad API design
|
||||
}
|
||||
|
||||
arg0[i] = ptr;
|
||||
@@ -121,7 +121,7 @@ bool js_gfx_Device_copyTextureToBuffers(se::State &s) { // NOLINT(readability-id
|
||||
assert(false);
|
||||
}
|
||||
} else {
|
||||
ptr = reinterpret_cast<uint8_t *>(value.asPtr());
|
||||
ptr = reinterpret_cast<uint8_t *>(value.asPtr()); // NOLINT(performance-no-int-to-ptr) script engine bad API design
|
||||
}
|
||||
|
||||
arg1[i] = ptr;
|
||||
@@ -167,7 +167,7 @@ bool js_gfx_Device_copyTexImagesToTexture(se::State &s) { // NOLINT(readability-
|
||||
value.toObject()->getTypedArrayData(&address, &dataLength);
|
||||
arg0[i] = address;
|
||||
} else {
|
||||
arg0[i] = reinterpret_cast<uint8_t *>(value.asPtr());
|
||||
arg0[i] = reinterpret_cast<uint8_t *>(value.asPtr()); // NOLINT(performance-no-int-to-ptr) script engine bad API design
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -229,8 +229,9 @@ static bool js_gfx_Device_createTexture(se::State &s) { // NOLINT(readability-id
|
||||
bool createTextureView = false;
|
||||
seval_to_boolean(args[1], &createTextureView);
|
||||
if (createTextureView) {
|
||||
auto *textureViewInfo = static_cast<cc::gfx::TextureViewInfo *>(args[0].toObject()->getPrivateData());
|
||||
texture = cobj->createTexture(*textureViewInfo);
|
||||
cc::gfx::TextureViewInfo textureViewInfo;
|
||||
sevalue_to_native(args[0], &textureViewInfo, s.thisObject());
|
||||
texture = cobj->createTexture(textureViewInfo);
|
||||
} else {
|
||||
cc::gfx::TextureInfo textureInfo;
|
||||
sevalue_to_native(args[0], &textureInfo, s.thisObject());
|
||||
@@ -260,11 +261,13 @@ static bool js_gfx_Buffer_initialize(se::State &s) { // NOLINT(readability-ident
|
||||
seval_to_boolean(args[1], &initWithBufferViewInfo);
|
||||
|
||||
if (initWithBufferViewInfo) {
|
||||
auto *bufferViewInfo = static_cast<cc::gfx::BufferViewInfo *>(args[0].toObject()->getPrivateData());
|
||||
cobj->initialize(*bufferViewInfo);
|
||||
cc::gfx::BufferViewInfo bufferViewInfo;
|
||||
sevalue_to_native(args[0], &bufferViewInfo, s.thisObject());
|
||||
cobj->initialize(bufferViewInfo);
|
||||
} else {
|
||||
auto *bufferInfo = static_cast<cc::gfx::BufferInfo *>(args[0].toObject()->getPrivateData());
|
||||
cobj->initialize(*bufferInfo);
|
||||
cc::gfx::BufferInfo bufferInfo;
|
||||
sevalue_to_native(args[0], &bufferInfo, s.thisObject());
|
||||
cobj->initialize(bufferInfo);
|
||||
}
|
||||
|
||||
ok &= boolean_to_seval(ok, &s.rval());
|
||||
@@ -289,11 +292,13 @@ static bool js_gfx_Texture_initialize(se::State &s) { // NOLINT(readability-iden
|
||||
seval_to_boolean(args[1], &initWithTextureViewInfo);
|
||||
|
||||
if (initWithTextureViewInfo) {
|
||||
auto *textureViewInfo = static_cast<cc::gfx::TextureViewInfo *>(args[0].toObject()->getPrivateData());
|
||||
cobj->initialize(*textureViewInfo);
|
||||
cc::gfx::TextureViewInfo textureViewInfo;
|
||||
sevalue_to_native(args[0], &textureViewInfo, s.thisObject());
|
||||
cobj->initialize(textureViewInfo);
|
||||
} else {
|
||||
auto *textureInfo = static_cast<cc::gfx::TextureInfo *>(args[0].toObject()->getPrivateData());
|
||||
cobj->initialize(*textureInfo);
|
||||
cc::gfx::TextureInfo textureInfo;
|
||||
sevalue_to_native(args[0], &textureInfo, s.thisObject());
|
||||
cobj->initialize(textureInfo);
|
||||
}
|
||||
|
||||
ok &= boolean_to_seval(ok, &s.rval());
|
||||
|
||||
@@ -54,6 +54,14 @@ public:
|
||||
inline void setInstanceCount(uint32_t count) { _drawInfo.instanceCount = count; }
|
||||
inline void setFirstInstance(uint32_t first) { _drawInfo.firstInstance = first; }
|
||||
|
||||
inline uint32_t getVertexCount() const { return _drawInfo.vertexCount; }
|
||||
inline uint32_t getFirstVertex() const { return _drawInfo.firstVertex; }
|
||||
inline uint32_t getIndexCount() const { return _drawInfo.indexCount; }
|
||||
inline uint32_t getFirstIndex() const { return _drawInfo.firstIndex; }
|
||||
inline uint32_t getVertexOffset() const { return _drawInfo.vertexOffset; }
|
||||
inline uint32_t getInstanceCount() const { return _drawInfo.instanceCount; }
|
||||
inline uint32_t getFirstInstance() const { return _drawInfo.firstInstance; }
|
||||
|
||||
protected:
|
||||
virtual void doInit(const InputAssemblerInfo &info) = 0;
|
||||
virtual void doDestroy() = 0;
|
||||
|
||||
@@ -137,22 +137,6 @@ void ForwardStage::dispenseRenderObject2Queues() {
|
||||
}
|
||||
}
|
||||
|
||||
void ForwardStage::recordCommands(scene::Camera *camera, gfx::RenderPass *renderPass) {
|
||||
auto * cmdBuff = _pipeline->getCommandBuffers()[0];
|
||||
const std::array<uint, 1> globalOffsets = {_pipeline->getPipelineUBO()->getCurrentCameraUBOOffset()};
|
||||
cmdBuff->bindDescriptorSet(globalSet, _pipeline->getDescriptorSet(), static_cast<uint>(globalOffsets.size()), globalOffsets.data());
|
||||
if (!_pipeline->getPipelineSceneData()->getRenderObjects().empty()) {
|
||||
_renderQueues[0]->recordCommandBuffer(_device, renderPass, cmdBuff);
|
||||
_instancedQueue->recordCommandBuffer(_device, renderPass, cmdBuff);
|
||||
_batchedQueue->recordCommandBuffer(_device, renderPass, cmdBuff);
|
||||
_additiveLightQueue->recordCommandBuffer(_device, renderPass, cmdBuff);
|
||||
_planarShadowQueue->recordCommandBuffer(_device, renderPass, cmdBuff);
|
||||
_renderQueues[1]->recordCommandBuffer(_device, renderPass, cmdBuff);
|
||||
}
|
||||
_uiPhase->render(camera, renderPass);
|
||||
renderProfiler(renderPass, cmdBuff, _pipeline->getProfiler(), camera->window->swapchain);
|
||||
}
|
||||
|
||||
void ForwardStage::render(scene::Camera *camera) {
|
||||
struct RenderData {
|
||||
framegraph::TextureHandle backBuffer;
|
||||
@@ -238,8 +222,21 @@ void ForwardStage::render(scene::Camera *camera) {
|
||||
builder.setViewport(viewport, _renderArea);
|
||||
};
|
||||
|
||||
auto forwardExec = [this, camera](const RenderData & /*data*/, const framegraph::DevicePassResourceTable &table) {
|
||||
recordCommands(camera, table.getRenderPass());
|
||||
auto offset = _pipeline->getPipelineUBO()->getCurrentCameraUBOOffset();
|
||||
auto forwardExec = [this, camera, offset](const RenderData & /*data*/, const framegraph::DevicePassResourceTable &table) {
|
||||
auto * renderPass = table.getRenderPass();
|
||||
auto * cmdBuff = _pipeline->getCommandBuffers()[0];
|
||||
cmdBuff->bindDescriptorSet(globalSet, _pipeline->getDescriptorSet(), 1, &offset);
|
||||
if (!_pipeline->getPipelineSceneData()->getRenderObjects().empty()) {
|
||||
_renderQueues[0]->recordCommandBuffer(_device, renderPass, cmdBuff);
|
||||
_instancedQueue->recordCommandBuffer(_device, renderPass, cmdBuff);
|
||||
_batchedQueue->recordCommandBuffer(_device, renderPass, cmdBuff);
|
||||
_additiveLightQueue->recordCommandBuffer(_device, renderPass, cmdBuff);
|
||||
_planarShadowQueue->recordCommandBuffer(_device, renderPass, cmdBuff);
|
||||
_renderQueues[1]->recordCommandBuffer(_device, renderPass, cmdBuff);
|
||||
}
|
||||
_uiPhase->render(camera, renderPass);
|
||||
renderProfiler(renderPass, cmdBuff, _pipeline->getProfiler(), camera->window->swapchain);
|
||||
};
|
||||
|
||||
// add pass
|
||||
|
||||
@@ -52,7 +52,6 @@ public:
|
||||
|
||||
private:
|
||||
void dispenseRenderObject2Queues();
|
||||
void recordCommands(scene::Camera *camera, gfx::RenderPass *renderPass);
|
||||
static RenderStageInfo initInfo;
|
||||
ForwardPipeline * _forwrdPipeline = nullptr;
|
||||
PlanarShadowQueue * _planarShadowQueue = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user