mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-04 18:42:40 +08:00
6ed4719968
* adding queue phase * adding per phase descriptor set * adding render phase descriptor set * Optimize memory usage and rendering time of WebPipeline (#106) * Pass ubo execution optimization (#107) * adding compute shader * add compute shader * add compute dispatch * add compute shader * adding subpass * add dummy web subpass builder * remove present pass * remove present pass * adding subpass to RenderGraph * fix unit test * lint fix * fix lint * adding raster subpass * native subpass builder added * Complete render phase to layoutgraph (#108) * rename RasterTag to RasterPassTag * rename ComputePass to Compute * subpassGraph added * add shading rate attachment * fix typo * RenderSwapchain default constructible * Optimize Execution Memory (#110) * add storage buffer/texture support * add storage buffer and shading rate texture * fix lint * fix typo * V3.7.2 pipeline (#109) * fix merge conflict --------- Co-authored-by: GengineJS <476393671@qq.com> Co-authored-by: Zeqiang Li <zeqiang-li@outlook.com>
97 lines
3.5 KiB
C++
97 lines
3.5 KiB
C++
#include "NativeUtils.h"
|
|
#include "cocos/renderer/gfx-base/GFXDevice.h"
|
|
#include "cocos/core/Root.h"
|
|
#include "cocos/application/ApplicationManager.h"
|
|
#include "NativePipelineTypes.h"
|
|
|
|
namespace cc {
|
|
namespace render {
|
|
|
|
void setupQuadVertexBuffer(gfx::Device& device, const Vec4& viewport, float vbData[16]) {
|
|
auto minX = static_cast<float>(viewport.x);
|
|
auto maxX = static_cast<float>(viewport.x + viewport.z);
|
|
auto minY = static_cast<float>(viewport.y);
|
|
auto maxY = static_cast<float>(viewport.y + viewport.w);
|
|
if (device.getCapabilities().screenSpaceSignY > 0) {
|
|
std::swap(minY, maxY);
|
|
}
|
|
int n = 0;
|
|
vbData[n++] = -1.0F;
|
|
vbData[n++] = -1.0F;
|
|
vbData[n++] = minX; // uv
|
|
vbData[n++] = maxY;
|
|
vbData[n++] = 1.0F;
|
|
vbData[n++] = -1.0F;
|
|
vbData[n++] = maxX;
|
|
vbData[n++] = maxY;
|
|
vbData[n++] = -1.0F;
|
|
vbData[n++] = 1.0F;
|
|
vbData[n++] = minX;
|
|
vbData[n++] = minY;
|
|
vbData[n++] = 1.0F;
|
|
vbData[n++] = 1.0F;
|
|
vbData[n++] = maxX;
|
|
vbData[n++] = minY;
|
|
}
|
|
|
|
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
|
|
void updateRasterPassConstants(uint32_t width, uint32_t height, Setter& setter) {
|
|
const auto& root = *Root::getInstance();
|
|
const auto shadingWidth = static_cast<float>(width);
|
|
const auto shadingHeight = static_cast<float>(height);
|
|
setter.setVec4(
|
|
"cc_time",
|
|
Vec4(
|
|
root.getCumulativeTime(),
|
|
root.getFrameTime(),
|
|
static_cast<float>(CC_CURRENT_ENGINE()->getTotalFrames()),
|
|
0.0F));
|
|
|
|
setter.setVec4(
|
|
"cc_screenSize",
|
|
Vec4(shadingWidth, shadingHeight, 1.0F / shadingWidth, 1.0F / shadingHeight));
|
|
setter.setVec4(
|
|
"cc_nativeSize",
|
|
Vec4(shadingWidth, shadingHeight, 1.0F / shadingWidth, 1.0F / shadingHeight));
|
|
#if 0
|
|
const auto *debugView = root.getDebugView();
|
|
if (debugView) {
|
|
setter.setVec4(
|
|
"cc_debug_view_mode",
|
|
Vec4(static_cast<float>(debugView->getSingleMode()),
|
|
debugView->isLightingWithAlbedo() ? 1.0F : 0.0F,
|
|
debugView->isCsmLayerColoration() ? 1.0F : 0.0F,
|
|
0.0F));
|
|
Vec4 debugPackVec{};
|
|
for (auto i = static_cast<uint32_t>(pipeline::DebugViewCompositeType::DIRECT_DIFFUSE);
|
|
i < static_cast<uint32_t>(pipeline::DebugViewCompositeType::MAX_BIT_COUNT); ++i) {
|
|
const auto idx = i % 4;
|
|
(&debugPackVec.x)[idx] = debugView->isCompositeModeEnabled(i) ? 1.0F : 0.0F;
|
|
const auto packIdx = static_cast<uint32_t>(floor(static_cast<float>(i) / 4.0F));
|
|
if (idx == 3) {
|
|
std::string name("cc_debug_view_composite_pack_");
|
|
name.append(std::to_string(packIdx + 1));
|
|
setter.setVec4(name, debugPackVec);
|
|
}
|
|
}
|
|
} else {
|
|
setter.setVec4("cc_debug_view_mode", Vec4(0.0F, 1.0F, 0.0F, 0.0F));
|
|
Vec4 debugPackVec{};
|
|
for (auto i = static_cast<uint32_t>(pipeline::DebugViewCompositeType::DIRECT_DIFFUSE);
|
|
i < static_cast<uint32_t>(pipeline::DebugViewCompositeType::MAX_BIT_COUNT); ++i) {
|
|
const auto idx = i % 4;
|
|
(&debugPackVec.x)[idx] = 1.0F;
|
|
const auto packIdx = static_cast<uint32_t>(floor(i / 4.0));
|
|
if (idx == 3) {
|
|
std::string name("cc_debug_view_composite_pack_");
|
|
name.append(std::to_string(packIdx + 1));
|
|
setter.setVec4(name, debugPackVec);
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|
|
} // namespace render
|
|
} // namespace cc
|