graphicsdriver/metal: Bug fix: Use correct pixel format for the screen

This commit is contained in:
Hajime Hoshi 2019-09-08 03:52:29 +09:00
parent ef91fb739f
commit 3fb9c02e2f

View File

@ -280,6 +280,7 @@ type rpsKey struct {
filter driver.Filter
address driver.Address
compositeMode driver.CompositeMode
screen bool
}
type Driver struct {
@ -511,6 +512,7 @@ func (d *Driver) Reset() error {
}
}
for _, screen := range []bool{false, true} {
for _, cm := range []bool{false, true} {
for _, a := range []driver.Address{
driver.AddressClampToZero,
@ -533,7 +535,12 @@ func (d *Driver) Reset() error {
VertexFunction: vs,
FragmentFunction: fs,
}
rpld.ColorAttachments[0].PixelFormat = mtl.PixelFormatRGBA8UNorm
pix := mtl.PixelFormatRGBA8UNorm
if screen {
pix = d.view.colorPixelFormat()
}
rpld.ColorAttachments[0].PixelFormat = pix
rpld.ColorAttachments[0].BlendingEnabled = true
src, dst := c.Operations()
@ -546,6 +553,7 @@ func (d *Driver) Reset() error {
return err
}
d.rpss[rpsKey{
screen: screen,
useColorM: cm,
filter: f,
address: a,
@ -555,6 +563,7 @@ func (d *Driver) Reset() error {
}
}
}
}
d.cq = d.view.getMTLDevice().MakeCommandQueue()
return nil
@ -604,6 +613,7 @@ func (d *Driver) Draw(indexLen int, indexOffset int, mode driver.CompositeMode,
rce.SetRenderPipelineState(d.screenRPS)
} else {
rce.SetRenderPipelineState(d.rpss[rpsKey{
screen: d.dst.screen,
useColorM: colorM != nil,
filter: filter,
address: address,