-
-
Notifications
You must be signed in to change notification settings - Fork 675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: MRT Proof of concept #2953
Conversation
bc1eae0
to
5b54a1d
Compare
Please update your PR for the latest main branch, thanks! |
@@ -440,6 +440,27 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderSrcImageCount]*Image, vertice | |||
i.drawTriangles(srcs, vertices, indices, blend, dstRegion, srcRegions, shader, uniforms, fillRule) | |||
} | |||
|
|||
func DrawTrianglesMRT(dsts [graphics.ShaderDstImageCount]*Image, srcs [graphics.ShaderSrcImageCount]*Image, vertices []float32, indices []uint32, blend graphicsdriver.Blend, dstRegion image.Rectangle, srcRegions [graphics.ShaderSrcImageCount]image.Rectangle, shader *Shader, uniforms []uint32, fillRule graphicsdriver.FillRule) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not unifying DrawTriangles with this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally thought I might have a lot of additional things to write and wanted to make it distinct, but I can merge them now!
Another point is that I was afraid of the cost of the copy of an extra array of 8 pointers in all paths with (5-6x layer depth, ebiten,ui,buffered,mipmap,atlas, etc..) which would apply to all other standard two-triangles DrawImage
call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another point is that I was afraid of the cost of the copy of an extra array of 8 pointers in all paths with (5-6x layer depth, ebiten,ui,buffered,mipmap,atlas, etc..) which would apply to all other standard two-triangles DrawImage call.
I don't think this would be problematic in terms of performance. Also, I'm not sure we really want 8 images (4 would be enough for example?).
// the value is kept and is not clamped. | ||
// | ||
// When the image i is disposed, DrawTrianglesShader does nothing. | ||
func DrawTrianglesShaderMRT(dsts [graphics.ShaderDstImageCount]*Image, vertices []Vertex, indices []uint16, shader *Shader, options *DrawTrianglesShaderOptions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to share most of implementations with DrawTriangles
@@ -211,6 +211,51 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderSrcImageCount]*Image, vertice | |||
i.pixels = nil | |||
} | |||
|
|||
func DrawTrianglesMRT(dsts [graphics.ShaderDstImageCount]*Image, srcs [graphics.ShaderSrcImageCount]*Image, vertices []float32, indices []uint32, blend graphicsdriver.Blend, dstRegion image.Rectangle, srcRegions [graphics.ShaderSrcImageCount]image.Rectangle, shader *atlas.Shader, uniforms []uint32, fillRule graphicsdriver.FillRule) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not unifying DrawTriangles with this?
// | ||
// If the source image is not specified, i.e., src is nil and there is no image in the uniform variables, the | ||
// elements for the source image are not used. | ||
func DrawTrianglesMRT(dsts [graphics.ShaderDstImageCount]*Image, srcs [graphics.ShaderSrcImageCount]*Image, vertices []float32, indices []uint32, blend graphicsdriver.Blend, dstRegion image.Rectangle, srcRegions [graphics.ShaderSrcImageCount]image.Rectangle, shader *Shader, uniforms []uint32, fillRule graphicsdriver.FillRule) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not unifying DrawTriangles with this?
Let's close this PR, since we require more 2D use cases and user requests regarding this feature: #2930 (comment) |
What issue is this addressing?
#2930
What this PR does | solves
This is a proof of concept of MRT (multiple render target), to investigate if the concept could be integrated to ebitengine, this is not a merge candidate for now.
go run ./examples/mrt
Notes:
*ebiten.Image
(as in different internal textures).examples/mrt
is probably to be removed and changed for a more relevant example, I put it there so that we can see a minimal reproduction of the feature temporarily