mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 17:05:38 +00:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user