Add compute pipeline and buffer layout support enhancements#41
Conversation
Code Review SummaryVerdict: Changes Requested (3 critical, 6 warnings, 6 suggestions) 对 #41 的全面回顾。总体架构设计良好,分层清晰(Extension 接口 → Mixin 注入 → Compute Pipeline → Binding Types)。Buffer Layout 重构从 UBO-only 泛化到通用系统,std140/std430 实现正确。但有 3 个关键 bug 需要修复。 🔴 Critical1. Compact constructor 接收的参数顺序为 this(
pipeline, textureSetup, pose,
x0, y0, x1, y1,
u0, u1, v0, v1, // ← BUG: 应为 u0, v0, u1, v1
color, scissorArea,
getBounds(x0, y0, x1, y1, pose, scissorArea)
);影响: 当通过 修复: 将第 54 行改为 2. Test
影响: 修复: 将 3.
同样, 影响: Debug label 会被绑定到错误的 GL 对象上,在 GPU debugger/RenderDoc 中无法正确识别 compute program。不影响运行正确性,但严重影响开发调试体验。 🟡 Warnings4. 如果 建议:在 ALRComputeProgramInstance program = ALRComputeShaderManager.INSTANCE.getShader(pipeline);
if (program == null || program == ALRComputeProgramInstance.INVALID) return;5. private final GpuDeviceBackend backend; // 仅在构造函数中赋值,从未被使用构造函数中 6. 7. 8. import javafx.util.Pair; // 未使用,Minecraft 环境通常不包含 JavaFX可能造成编译警告或错误。需要移除该 import。 🟢 Suggestions9.
10. Debug label 仍使用 11. 测试覆盖全面(std140 alignment、struct array padding、索引写入、std430 紧凑布局),但使用 12. 13. int anInt = counterData.getInt(); // 读取后丢弃可能是调试遗留。建议移除或添加用途说明。 14. 当前 ✅ Looks Good
Reviewed by Hermes Agent |
✅ 更新 — 推动修复验证新的推送解决了我之前报告的 全部 3 个关键问题 以及若干警告。谢谢快速修复! 🔴 已修复 (3/3)
🟡 已修复 (4/6)
🟢 建议尚未处理(均为非阻塞)
以上建议不会阻止合入。代码质量良好,可以合并 ✅ 由 Hermes Agent 更新 — 改动已验证 |
概述
为 AnvilLib Rendering 模块添加 Compute Pipeline 支持和 Buffer Layout 系统重构。这是为后续 GPU 计算管线(如后处理效果、粒子模拟等)打基础。
变更内容
Compute Pipeline 支持
新增完整的 Compute Pipeline 抽象层,基于 Minecraft Blaze3D 渲染后端扩展:
ALRComputePipeline/ALRComputePass— Compute 管线与通道顶层抽象;ALRComputePassBackend/GlComputePassBackend— OpenGL 后端实现(封装 glDispatchCompute + 内存屏障)ALRComputeShaderManager/ALRComputeProgramInstance/ShaderResourceTypeUniformBlockBinding/ShaderStorageBinding/ImageBinding/AtomicCounterBinding/TextureBindingALRGpuDeviceExtension/ALRCommandEncoderExtension/MemoryBarrierFlag/ALRComputeCapabilitiesCommandEncoderMixin/GlCommandEncoderMixin/GpuDeviceMixin/GlDeviceMixin/GlDebugLabelMixinBuffer Layout 系统重构
将原先仅支持 UBO 的
UboLayout*类重构为通用的BufferObjectLayout*系统:BufferObjectLayoutDefinition/BufferObjectLayoutEntry/BufferObjectLayoutEntryType/ShaderBufferObjectUsage/BufferLayout/BufferSizeCalculator/BufferWriterStd140SizeCalculator/Std140Writer(替换旧的UboLayoutDefinition/UboLayoutEntry/UboLayoutEntryType)Std430SizeCalculator/Std430Writer(用于 SSBO)Std140LayoutRulesTest(139 行,覆盖所有 std140 对齐规则)Blur 重构
BlurParametersUbo从bloom包迁移到blur包,与GaussianBlur统一管理BlurParametersUbo.java(旧 bloom 包下的)中冗余引用事件系统扩展
MainTargetResizeEvent— 主渲染目标尺寸变化事件RegisterComputePipelinesEvent— Compute 管线注册事件GUI 渲染增强
DynamicTextureBlitRenderState— 动态纹理 Blit 渲染状态,支持透明纹理渲染GuiRenderExtras大幅扩展(+138 行),新增辅助渲染方法配置与 Mixin
module.rendering/build.gradle添加依赖声明;module.gradle配置更新anvillib_rendering.mixins.json注册新的 Mixin 类;accesstransformer.cfg添加所需 AT 条目测试
module.test):ComputeSupport(240 行测试基础设施)、TestPipelines、4 个 Compute Shader 测试资源(add.csh / empty.csh / image_and_sampler.csh / test.csh)TestCachedRenderer更新适配兼容性