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