-
Notifications
You must be signed in to change notification settings - Fork 636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
支持 Point / Line / Polygon / Heatmap 在 WebGPU 下的渲染 #2225
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
point image 报错:
原因是 fillimage_frag.glsl 中存在多余的 // vertex shader
out vec2 v1;
out vec2 v2;
// fragment shader
in vec2 v2;
in vec2 v1; // 顺序不一致会报错 在生成 WGSL 时,会根据 varying 出现的顺序分配 location,因此顺序不一致就没法匹配:
|
// before
layout(location = 13) in vec3 a_Normal;
layout(location = 14) in float a_Total_Distance;
// after
layout(location = 13) in vec4 a_Normal_Total_Distance; line 这种可以合并,参与数据映射的 Vertex 目前不能合并,否则会影响数据更新,如shape/size/offset 目前不能合并 |
是的,所以在 line 这个例子里,把不会发生更新的 a_Normal 和 a_Total_Distance 合并了。 |
lzxue
approved these changes
Jan 9, 2024
lzxue
pushed a commit
that referenced
this pull request
Jan 10, 2024
* fix: webgpu point fill example * fix: adjust order of varying in fill image shader * fix: remove redundant varying in extrude vert shader * fix: recreate main & depth rt when resizing * fix: load image in webgpu * fix: heatmap * fix: heatmap grid3d in webgpu * fix: heatmap grid3d in webgpu * fix: line * fix: change readpixel from sync to async * fix: resize picking fbo * fix: picking in webgpu * fix: arc line layer * fix: use diagnosticDerivativeUniformity in water demo * fix: add render cache * fix: point text layer * chore: update point text layer snapshot * fix: raster layer * chore: add screenshot callback on test cases * chore: sleep * chore: cancel point image test case for now
lzxue
added a commit
that referenced
this pull request
Jan 10, 2024
* fix: fillImage中uniform没对齐的bug * feat: 适配天地图的底图 * chore: 修改天地图map中lngLatToCoord的方法实现 * feat: 添加天地图的markerContainer,但是不能更新其定位 * fix: marker和popup在地图拖动时不跟随的bug * feat: 图层显隐组件 LayerSwitch 新增单选模式 (#2211) * feat: layerSwitch组件新增单选属性 * chore: 更新markdown路径 * feat: layerSwitch组件添加单选模式 * chore: 恢复setting配置 * chore: 删除调试代码 --------- Co-authored-by: 谨欣 <[email protected]> * Fix raster webgl1 (#2213) * chore: g-device version & dev command * fix: raster g.LUMINANCE 回滚到webgl1 * chore: publish (#2214) * fix: single component data texture (#2215) * fix: 修复图层显隐控件LayerSwitch单选模式下未默认展示单个图层问题 (#2218) * fix: 修复图层显隐控件LayerSwitch单选模式下未默认展示单个图层问题 * feat: 图层显隐控件选择模式更新时,销毁图层内容重建 * chore: 修复空格 * chore: 新增todo * feat: 修改单选模式只显示第一个图层逻辑到onAdd函数中 --------- Co-authored-by: 谨欣 <[email protected]> * chore: multiband rgb raster parse (#2219) * chore: multiband rgb raster parse * fix: 单测 * chore: publish (#2220) * fix: 修复配置更新时,处理单选模式图层问题 (#2221) Co-authored-by: 谨欣 <[email protected]> * Update site&新增 raster ndi 计算 (#2222) * feat: 添加归一化指数 parse * chore: 更新文档 * Fix encode update (#2229) * fix: encode update * fix: encode update * chore: publish (#2230) * fix: 修复图层隐藏时,LayerPopup 未跟随隐藏的问题 (#2231) * chore: publish (#2232) * fix: 修正L7Plot官网图表示例按钮跳转链接 (#2233) * fix: 修复配置更新时,处理单选模式图层问题 * feat: 修改函数名 * fix: 修正L7Plot官网图表示例按钮跳转链接 --------- Co-authored-by: 谨欣 <[email protected]> * chore: publish (#2235) * Migrate tile layer (#2236) * fix: 修复栅格瓦片显示 * fix: 修复冲突 * chore: renderer ts 定义 * docs: add 矢量瓦片demo * fix: clear depth & stencil before rende mask * chore: update tile snapshot * chore: update tile vector snapshot --------- Co-authored-by: yuqi.pyq <[email protected]> * chore: add threejs demo (#2245) * chore: add threejs demo * docs: add screenshot url --------- Co-authored-by: zhnny <[email protected]> * 支持 WebGPU 渲染 (#2225) * fix: webgpu point fill example * fix: adjust order of varying in fill image shader * fix: remove redundant varying in extrude vert shader * fix: recreate main & depth rt when resizing * fix: load image in webgpu * fix: heatmap * fix: heatmap grid3d in webgpu * fix: heatmap grid3d in webgpu * fix: line * fix: change readpixel from sync to async * fix: resize picking fbo * fix: picking in webgpu * fix: arc line layer * fix: use diagnosticDerivativeUniformity in water demo * fix: add render cache * fix: point text layer * chore: update point text layer snapshot * fix: raster layer * chore: add screenshot callback on test cases * chore: sleep * chore: cancel point image test case for now * fix: 合并冲突 * fix: fillImage中uniform没对齐的bug * chore: 天地图导出类型 --------- Co-authored-by: huyang <[email protected]> Co-authored-by: Dreammy23 <[email protected]> Co-authored-by: 谨欣 <[email protected]> Co-authored-by: @thinkingGIS <[email protected]> Co-authored-by: xiaoiver <[email protected]> Co-authored-by: heiyexing <[email protected]> Co-authored-by: zhnny <[email protected]> Co-authored-by: zhnny <[email protected]> Co-authored-by: lzxue <[email protected]>
lzxue
added a commit
that referenced
this pull request
Jan 16, 2024
* fix: fillImage中uniform没对齐的bug * feat: 适配天地图的底图 * chore: 修改天地图map中lngLatToCoord的方法实现 * feat: 添加天地图的markerContainer,但是不能更新其定位 * fix: marker和popup在地图拖动时不跟随的bug * feat: 图层显隐组件 LayerSwitch 新增单选模式 (#2211) * feat: layerSwitch组件新增单选属性 * chore: 更新markdown路径 * feat: layerSwitch组件添加单选模式 * chore: 恢复setting配置 * chore: 删除调试代码 --------- Co-authored-by: 谨欣 <[email protected]> * Fix raster webgl1 (#2213) * chore: g-device version & dev command * fix: raster g.LUMINANCE 回滚到webgl1 * chore: publish (#2214) * fix: single component data texture (#2215) * fix: 修复图层显隐控件LayerSwitch单选模式下未默认展示单个图层问题 (#2218) * fix: 修复图层显隐控件LayerSwitch单选模式下未默认展示单个图层问题 * feat: 图层显隐控件选择模式更新时,销毁图层内容重建 * chore: 修复空格 * chore: 新增todo * feat: 修改单选模式只显示第一个图层逻辑到onAdd函数中 --------- Co-authored-by: 谨欣 <[email protected]> * chore: multiband rgb raster parse (#2219) * chore: multiband rgb raster parse * fix: 单测 * chore: publish (#2220) * fix: 修复配置更新时,处理单选模式图层问题 (#2221) Co-authored-by: 谨欣 <[email protected]> * Update site&新增 raster ndi 计算 (#2222) * feat: 添加归一化指数 parse * chore: 更新文档 * Fix encode update (#2229) * fix: encode update * fix: encode update * chore: publish (#2230) * fix: 修复图层隐藏时,LayerPopup 未跟随隐藏的问题 (#2231) * chore: publish (#2232) * fix: 修正L7Plot官网图表示例按钮跳转链接 (#2233) * fix: 修复配置更新时,处理单选模式图层问题 * feat: 修改函数名 * fix: 修正L7Plot官网图表示例按钮跳转链接 --------- Co-authored-by: 谨欣 <[email protected]> * chore: publish (#2235) * Migrate tile layer (#2236) * fix: 修复栅格瓦片显示 * fix: 修复冲突 * chore: renderer ts 定义 * docs: add 矢量瓦片demo * fix: clear depth & stencil before rende mask * chore: update tile snapshot * chore: update tile vector snapshot --------- Co-authored-by: yuqi.pyq <[email protected]> * chore: add threejs demo (#2245) * chore: add threejs demo * docs: add screenshot url --------- Co-authored-by: zhnny <[email protected]> * 支持 WebGPU 渲染 (#2225) * fix: webgpu point fill example * fix: adjust order of varying in fill image shader * fix: remove redundant varying in extrude vert shader * fix: recreate main & depth rt when resizing * fix: load image in webgpu * fix: heatmap * fix: heatmap grid3d in webgpu * fix: heatmap grid3d in webgpu * fix: line * fix: change readpixel from sync to async * fix: resize picking fbo * fix: picking in webgpu * fix: arc line layer * fix: use diagnosticDerivativeUniformity in water demo * fix: add render cache * fix: point text layer * chore: update point text layer snapshot * fix: raster layer * chore: add screenshot callback on test cases * chore: sleep * chore: cancel point image test case for now * fix: 合并冲突 * fix: fillImage中uniform没对齐的bug * chore: 天地图导出类型 * feat: wms 支持 url service * feat: tdt fit bounds * docs: 补充 polygon linear demo --------- Co-authored-by: huyang <[email protected]> Co-authored-by: Dreammy23 <[email protected]> Co-authored-by: 谨欣 <[email protected]> Co-authored-by: xiaoiver <[email protected]> Co-authored-by: heiyexing <[email protected]> Co-authored-by: zhnny <[email protected]> Co-authored-by: zhnny <[email protected]>
xiaoiver
changed the title
支持 WebGPU 渲染
支持 Point / Line / Polygon / Heatmap 在 WebGPU 下的渲染
Jan 22, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[English Template / 英文模板]
🤔 这个变动的性质是?
🔗 相关 Issue
验证 WebGPU 渲染能力。新增示例:
控制台的 warning 可以忽略:
不过也能看出
project_float_meter
这个函数确实有执行不到的代码,可以优化一下:💡 需求背景和解决方案
启用 WebGPU 渲染器方式如下:
该 WASM 的主要作用是将 GLSL 440 转成 WebGPU 需要的 WGSL。
局限性 & 差异点
WebGPU 和 WebGL 存在不少差异
gl_PointSize 不支持
gpuweb/gpuweb#1190
WGSL 不支持 gl_PointSize
wgsl::write_string Unsupported builtin PointSize
因此 point billboard / normal 没法运行textureSample 只能写在确定分支中
例如 polygon water 的例子中如下写法会报错:
解决办法是在顶部添加:https://www.w3.org/TR/WGSL/#example-70cf6bac
可以在 Model 中添加配置,开启后在编译成 WGSL 之后添加。
flip Y
在热力图示例中,需要使用 framebuffer 中的纹理,此时需要根据
VIEWPORT_ORIGIN_TL
判断是否翻转 Y 轴。该变量由 @antv/g-device-api 添加,WebGL 1/2 下不写入,WebGPU 下才写入:gpuweb/gpuweb#416
Vertex buffer 数量限制
最多 8 个,超出会报错:
因此类似 line 中的写法需要合并,减少数目:
异步读取纹理
WebGPU 中读取纹理是一个异步操作,而从同步改成异步会影响 render service 接口。antvis/g-device-api#130
这里的改动没法避免,在 Babylon.js 中也是 breaking change:
https://doc.babylonjs.com/setup/support/webGPU/webGPUBreakingChanges#readpixels-is-now-asynchronous
纹理存储格式
rgba8unorm 和 bgra8unorm 这两种纹理格式在 Shader 中都按 rgba 访问,但内存中的存储却不一样:
https://www.w3.org/TR/WGSL/#texel-format-bgra8unorm
由于我们使用的是 bgra8unorm,因此在拾取后需要交换 b 和 r 再 decode 回 feature id。
不支持创建宽高为 0 的纹理
报错信息如下:
改成宽高为 1
截图测试
针对一些测试用例渲染前需要长时间加载数据,增加了一个钩子 screenshot
测试用例可以适时调用,通知 Playwright 截图:
📝 更新日志
☑️ 请求合并前的自查清单