2026-03-26 21:32:43 +08:00
|
|
|
|
# RenderSurface::RenderSurface
|
|
|
|
|
|
|
2026-04-04 17:35:23 +08:00
|
|
|
|
构造一个只描述渲染目标状态的 `RenderSurface`。
|
2026-03-26 21:32:43 +08:00
|
|
|
|
|
|
|
|
|
|
```cpp
|
2026-04-04 17:35:23 +08:00
|
|
|
|
RenderSurface();
|
2026-03-26 21:32:43 +08:00
|
|
|
|
RenderSurface(uint32_t width, uint32_t height);
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2026-04-04 17:35:23 +08:00
|
|
|
|
## 参数
|
2026-03-26 21:32:43 +08:00
|
|
|
|
|
2026-04-04 17:35:23 +08:00
|
|
|
|
- `width` - 初始逻辑宽度。
|
|
|
|
|
|
- `height` - 初始逻辑高度。
|
|
|
|
|
|
|
|
|
|
|
|
## 当前语义
|
|
|
|
|
|
|
|
|
|
|
|
- 默认构造得到 `0 x 0` 的空 surface;带参构造只写入 `width / height`。
|
|
|
|
|
|
- 构造函数不会自动创建颜色附件、深度附件或任何底层 render target 资源。
|
|
|
|
|
|
- 初始状态下:
|
|
|
|
|
|
- 没有颜色附件。
|
|
|
|
|
|
- 深度附件为 `nullptr`。
|
|
|
|
|
|
- 未启用自定义 render area。
|
|
|
|
|
|
- 未启用 clear-color override。
|
|
|
|
|
|
- 自动颜色状态切换开关为开启。
|
|
|
|
|
|
- `colorStateBefore` 与 `colorStateAfter` 都默认是 `Present`。
|
|
|
|
|
|
|
|
|
|
|
|
## 设计说明
|
|
|
|
|
|
|
|
|
|
|
|
- `RenderSurface` 只是一次渲染提交使用的“目标描述”,不是 swap chain、framebuffer 或纹理资源的拥有者。
|
|
|
|
|
|
- 调用方通常先构造 surface,再通过 [SetColorAttachment](SetColorAttachment.md)、[SetDepthAttachment](SetDepthAttachment.md)、[SetRenderArea](SetRenderArea.md) 等接口补齐实际目标配置。
|
|
|
|
|
|
|
|
|
|
|
|
## 测试覆盖
|
|
|
|
|
|
|
|
|
|
|
|
- `tests/Rendering/unit/test_camera_scene_renderer.cpp` 验证了仅设置宽高的 surface 也会生成覆盖整张 surface 的默认 render area。
|
|
|
|
|
|
- `tests/Editor/test_viewport_host_surface_utils.cpp` 验证了编辑器辅助函数会基于构造出的 surface 继续注入附件和颜色状态。
|
2026-03-26 21:32:43 +08:00
|
|
|
|
|
|
|
|
|
|
## 相关文档
|
|
|
|
|
|
|
2026-04-04 17:35:23 +08:00
|
|
|
|
- [RenderSurface](RenderSurface.md)
|
2026-03-26 21:32:43 +08:00
|
|
|
|
- [SetSize](SetSize.md)
|
2026-04-04 17:35:23 +08:00
|
|
|
|
- [SetColorAttachment](SetColorAttachment.md)
|
|
|
|
|
|
- [SetDepthAttachment](SetDepthAttachment.md)
|