mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 01:45:36 +00:00
gpu: introduce driver.Device.PrepareTexture and use it in renderers
Vulkan textures (VkImage) are always in a particular layout, where each layout is optimized for a particular use (transfer, sampling, compute storage). Vulkan allows layout transitions everywhere except inside render passes. This change adds driver.Device.PrepareTexture for instructing the driver to switch a texture to a layout for sampling in preparation for using it in a render pass. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -633,6 +633,8 @@ func (t *Texture) Release() {
|
||||
*t = Texture{}
|
||||
}
|
||||
|
||||
func (b *Backend) PrepareTexture(tex driver.Texture) {}
|
||||
|
||||
func (b *Backend) BindTexture(unit int, tex driver.Texture) {
|
||||
t := tex.(*Texture)
|
||||
b.ctx.PSSetSamplers(uint32(unit), t.sampler)
|
||||
|
||||
@@ -37,6 +37,7 @@ type Device interface {
|
||||
|
||||
BeginRenderPass(f Framebuffer, desc LoadDesc)
|
||||
EndRenderPass()
|
||||
PrepareTexture(t Texture)
|
||||
BindProgram(p Program)
|
||||
BindPipeline(p Pipeline)
|
||||
BindTexture(unit int, t Texture)
|
||||
|
||||
@@ -931,6 +931,8 @@ func (p *Pipeline) Release() {
|
||||
*p = Pipeline{}
|
||||
}
|
||||
|
||||
func (b *Backend) PrepareTexture(tex driver.Texture) {}
|
||||
|
||||
func (b *Backend) BindTexture(unit int, tex driver.Texture) {
|
||||
t := tex.(*Texture)
|
||||
if enc := b.renderEnc; enc != 0 {
|
||||
|
||||
@@ -1202,6 +1202,8 @@ func toTexFilter(f driver.TextureFilter) int {
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Backend) PrepareTexture(tex driver.Texture) {}
|
||||
|
||||
func (b *Backend) BindTexture(unit int, t driver.Texture) {
|
||||
b.glstate.bindTexture(b.funcs, unit, t.(*texture).obj)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user