-
Notifications
You must be signed in to change notification settings - Fork 698
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
Renderer Task Queue #547
Comments
Thanks for picking this up. I'm not sure if there's an alternative to a queue. The problem that occurs when trying to create objects during a render cycle is that it will fail when trying to create shaders, textures, etc. The quick & dirty solution in #112 reflects this. Here we just wait for the rendering to finish and then we create our objects. There might be an alternative but I'm not aware of it. I'll investigate further. |
@MasDennis Well I'm still a few weeks from getting to it so I will think about it as well. I'll post any ideas/questions here including my intention when I have one if we have not come to a mutual conclusion by then. |
A few weeks ago #546 was merged in to fix #543. After thinking about it more and moving forward on the scene graph implementation I need to take care of this because thread safety is becoming a bit of an issue and I only intend to allow the GL thread to touch the scenegraph regulated by Here is what I tentatively propose to do:
I apologize for not having thought this through in its entirety prior to my camera and concurrency pull requests, but the full extent of how these could cause thread bugs did not come to mind until I got far into the scenegraph. Please let me know what you guys think. |
It sounds like a well thought out solution to me. I agree on restricting the access to I like |
@ToxicBakery When I wake up in the mornings now I check my phone for the usually two dozen or so GitHub related emails. When I read this one I couldn't stop laughing for a good 5 minutes. I feel like I have been coming across as a thread-safety warlord, and that that picture really was beyond amusing. @MasDennis I will change the getters to return copies and document them clearly (including names). As for POJO vs. Interface I had not decided. If I store them as objects, I need to cast them up to their types to store them internally and the ENUM would be a definition in |
@jwoolston Glad I could help. Crusades are fine, I have gone on several memory crusades in my history of interaction with Rajawali so you'll hear no complaints from me. For FrameTask, I am trying to follow in what the conversation is about. My understanding of FrameTask is work to be done when the time is correct in the life cycle. Such work would be adding/removing of objects, movements, changing textures, etc. Is this a correct understanding for the intent of FrameTask? If this is the case, then all I can say is o.O. You have your work cut out for you as that, running it through my head really quick, seems like it would involve a LOT of work. |
@ToxicBakery only adding/removing of things. Stepping the animations will still be left to however the replacement animation framework handles it as I did not want to clutter/convolute things too much. The big issue here that I am trying to fix is making sure that these lists which need to be iterated are controlled more carefully so that the library can handle the thread safety needs of the library. As long as the animations are stepped by the gl thread either before or after (I vote for after) the frame tasks are performed, everyone will be happy I think. Texture changing I had not considered, I will add that as well. If you think the stepping of animations should be added in, I am open to it. This is pretty extensible so it would be pretty simple to add new tasks, which is something I was going for. As into crusading for thread safety as I am right now, I am conscious of the performance hit it can cause if performed unnecessarily, which is why I am inclined to move all of it into |
Well instead of standalone frame task class, what about FrameTask instead being AFrameTaks which can be extended by ATransformable3D. I only suggest this as more classes = more memory and more garbage collection creating and destroying objects. Since we can not avoid creating ATransformable objects, it may be good to attach code via an abstract super class that performs these general FrameTask actions. Additionally in the future FrameTask could be extended by Animation/Texture/Material classes as needed should we decide it to be necessary. |
@ToxicBakery Yea I can see the logic in that, it also simplifies the task class. Do you see any issues with allowing mutability to the task to be performed? |
I prefer mutability in 'automated' processes. I think it will provide greater flexibility down the line. Granted your proposed implementation would still allow for mutability by extended the FrameTask class. |
I am all in favor of reducing garbage. I am leaving a |
It is technically possible with a
Number 1 seems more generic to me, allowing users to sacrifice frame rate as they see fit. 2 would keep things more consistent frame to frame when there was a lot to be done. It is not as universal though, but could potentially be made so by using an Your thoughts? |
Also, should the various has methods be protected or public? |
It should be whatever makes the most sense for each particular method. I don't think there is any overarching answer. |
Its a work in progress but if anyone would like to take a look I'd like some input. I feel like there is a lot of repetitive code but I'm pretty sure there is no way around it. |
Sorry, branch is here: https://github.com/Tenkiv/Rajawali/tree/frame_task_queue |
I was thinking I could make the addChild/Plugin/Camera and removeChild/Plugin/Camera etc methods queueAddTask() queueRemoveTask etc which would take the various things, figure out the appropriate task values and go from there. This would be a breaking change what is probably one of the most commonly used methods though. |
@ToxicBakery Ian you had some input on the camera methods when I first added multiple cameras so I'd like your input on an issue here. With the task queue, there is no way to correctly return the index a camera will be added at, so the method |
I think realistically most applications would only have a few cameras so if the developer was tasked with keeping track of the cameras themselves, I believe this would be acceptable. If you go this route, then yes, removing int returns are pointless. Actually the entire getCamera method group would not be necessary I believe. Instead the only methods would be the following. addCamera(ACamera camera);
removeCamera(ACamera camera);
// Might want to use a different name than this but I like 'switchTo' personally.
switchToCamera(ACamera camera); |
Ok, I suppose there will just be some tasks which for certain objects are meaningless. I will document them accordingly. |
@MasDennis and @ToxicBakery I would really love to hear your input on my question above. I am concerned about adding a bunch of similar methods, but don't want to explicitly make this change as it will break a lot of initScene() calls. |
I'm 100% for breaking changes that make sense. In the case of SceneGraph it makes sense in my opinion as it is a better direction for the engine. I am considering changes like this for animations in the future as the current animation implementation and the rewrite both leave something to be desired that I think I can improve on. Anyways I try to always look at problems from the implementation point of view. That is, I write some suedo code that represents what my proposed internal implementation will support. Based on the suedo codeI can judge if the implementation makes sense. Is it easy to use, is it easy to understand? If it does not score well against either of those questions it would be good to consider changing the internals until the suedo code becomes something enjoyable to write and understand. I know this is not a specific answer and more of a process but I think you can use it to answer your question. Write a sample of how you would use it and then decide if you are happy with that. |
Thanks. That does pretty well answer the question. This is the first time I am being allowed to contribute so much to a repository that is not private to the company so I just want to make sure I follow with the direction everyone else is interested in having it go. |
I'm pretty sure the only rule here is that whoever breaks it has to buy the first round. |
Well I think @daveHD and I are the only two people remotely close. When I butcher it I guess I'll need to fed ex a box of newcastle then. |
@jwoolston Rajawali has so much activity lately that it is hard to keep track of everything that's going on :) I am in favor of the changes you proposed. I agree with @ToxicBakery that breaking stuff is acceptable when it benefits the framework in the long run. Although we'll probably have to think about release management as opposed to ad hoc updates. It is probably a good idea to set up a dev branch. The buying rounds rule sounds great. Very expensive for me though since most contributors are based in the US :) I have to say that American micro breweries are producing a lot of great beer! I was in Montana a few years ago and had several local beers in a place called Whitefish (can't remember the names but they were tasty). I also had a few good ones in Brooklyn a few months ago. Getting thirsty now! Anchor Stream, Arrogant Bastard Ale, Sierra Nevada Pale Ale ... yummm .. Excessively off topic. |
@MasDennis Yea I think a few crusades have been initiated. It's good to see though, I feel like I picked the right engine. |
I can supply the microbrew. We have tons of it here in California.... unfortunately all these changes are above my paygrade or I'd be happy to lend more help. |
@MasDennis @AndrewJo and anyone else who knows. I could use some input on how textures work. I have never tried fiddling with textures after initScene(). What happens if you do? Do they need to be included here? |
I think they should be included, there are a number of unexpected issues with updating textures on the fly in my experience. |
@Davhed Oi....now I have to figure out how to make that happen with the 30 or so possible method calls in mTextureManager....looks like I need some ENUMS. |
@jwoolston Yes. The texture manager and its methods. It has grown "organically" so to speak :). This is something that has been bugging me for some time. I've never found the time to tame this beast. Basically we have the same problems with textures & concurrency. There's also the problem that the textures cannot be updated during a render cycle. This is catered for in the texture manager though. I think I'll pick this one up. This has higher priority than md5 animation. Let me have a think about this. I'll come back to you with proposed changes this evening. |
Part of it is my fault when I added all those method calls for different texture compression types. I think we should probably have an abstract class which others extend from so we could have something like BitmapTexture, ETCTexture, PowerVRTexture, S3TCTexture classes, etc. which might help organize the API. |
Yes, either an abstract class or a Or maybe we could do a combination. The user would never create instances of PowerVRTexture, S3TCTexture etc themselves but this would be done by the texture manager. Maybe something like TextureConfig config = new TextureConfig();
config.setMipmap(true);
config.setRecycle(false);
config.setCompressionType(CompressionType.NONE); // default
// or
config.setCompressionType(CompressionType.S3TC);
mTextureManager.addTexture(Bitmap bitmap, TextureConfig config); Any thoughts? |
For compressed textures, we can't pass in a Bitmap object. It needs to be a ByteBuffer. Also, each compression methods use vastly different configuration options (see #311). Do you have any idea as to how we could reorganize the framework? |
Of course. Let me have a think about this. I'll look at it tonight. |
@MasDennis, alright. I'll bundle everything else up in the meantime. I was headed in the direction of a package class like you said, but only for the task queue. |
@MasDennis (@AndrewJo ... you get a tag because it affects your plugins also) another interesting issue here is what to do about the |
Can't you make it |
I can, but there are 3 members that all tasks must have in one form or another. |
If you make it an interface, wouldn't you be able to guarantee all tasks will have those 3 members? I'm guessing you have some implementations in the abstract class which is why you went with abstract class in the first place. |
I do have some implementations in the abstract yes, but its not that big of a deal. Sorry, my OOP terminology was flawed...there are 3 fields. |
I suppose I indirectly enforce having those fields through the related methods, I just find it inconvenient that they need to be defined in each implimentation. |
As much as I love the picture in this thread, #651 brings this full circle. |
Epic work Jared! |
Thanks! There's more where that came from! |
Great stuff. Thanks for this! |
I'll try to keep up. |
This was initially brought up in #543 but I thought it deserves a dedicated discussion.
I have had need of adding and removing objects from the scene at run time after it is initially created primarily for testing the scene graph stuff I'm working on but I believe I will need to do this in the app that I am currently working on as well. I am planning to work on a solution to this after I finish up the scene graph so I would like to start getting peoples thoughts on a good way of doing this. I know something to this effect could be accomplish by controlling if things are hidden or not but this seems cumbersome and not fully effective to me.
@ToxicBakery suggested a queue of some kind but from what I understand has concerns about the overall latent weight this would have. Following @MasDennis's suggestion in #112 someone can add object in onDrawFrame() but iterating them has some definite concurrency risks, which have been reduced with #546.
I will need something to be able to do this so I certainly don't mind doing it in a way you guys would be agreeable with. Anyone have some thoughts to share?
TODO List
Add PostProcessingFilter supportNot handling this at the momentPostProcessingFilterPostProcessingFilterPostProcessingFilterPostProcessingFilterPostProcessingFilterThe text was updated successfully, but these errors were encountered: