gpu/internal,internal/gl: add support for strided texture uploads

The CPU fallback of the compute renderer needs to upload subtextures
from a larger image.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-07-19 19:01:51 +02:00
parent abfbeb87cc
commit 60a47e7de5
8 changed files with 41 additions and 27 deletions
+2 -5
View File
@@ -167,7 +167,7 @@ type Timer interface {
}
type Texture interface {
Upload(offset, size image.Point, pixels []byte)
Upload(offset, size image.Point, pixels []byte, stride int)
Release()
}
@@ -261,11 +261,8 @@ func flipImageY(stride, height int, pixels []byte) {
func UploadImage(t Texture, offset image.Point, img *image.RGBA) {
var pixels []byte
size := img.Bounds().Size()
if img.Stride != size.X*4 {
panic("unsupported stride")
}
start := img.PixOffset(0, 0)
end := img.PixOffset(size.X, size.Y-1)
pixels = img.Pix[start:end]
t.Upload(offset, size, pixels)
t.Upload(offset, size, pixels, img.Stride)
}