antvis/g-device-api

setScissorRect 在 WebGL 和 WebGPU 下效果不一致

xiaoiver opened this issue · 4 comments

renderPass.setScissorRect(0, 0, 500, 500);

WebGL 和 WebGPU 的坐标原点不同:

截屏2023-09-26 上午10 09 46 截屏2023-09-26 上午10 09 57

setViewport 同理

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Title: setScissorRect has inconsistent effects under WebGL and WebGPU

renderPass.setScissorRect(0, 0, 500, 500);

The coordinate origins of WebGL and WebGPU are different:

Screenshot 2023-09-26 10 09 46 am Screenshot 2023-09-26 10 09 57 am

固定原点为左下角,在 setViewport / ScissorRect 时,需要换算反转下 Y 轴:

private flipY(y: number, h: number) {
  const height = this.device['swapChainHeight'];
  return height - y - h;
}

另外在读取纹理数据时,WebGL 同样也是从左下角开始,而 WebGPU 从左上角开始,也需要统一 Readback 中的实现

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


In addition, when reading texture data, WebGL also starts from the lower left corner, while WebGPU starts from the upper left corner, and the implementation in Readback also needs to be unified.