Skip to content
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

cellCamera: Improvements and refactoring #10818

Closed
wants to merge 3 commits into from

Conversation

elad335
Copy link
Contributor

@elad335 elad335 commented Sep 4, 2021

  • Fixed cellCameraEnd memleak.
  • Fixed many error checks of null handler.
  • Fixed cellCameraGetBufferSize. (override width/height, not bytesize)
  • Fixed cellCameraIsAttached, remove hacks!
  • Fixed cellCameraOpenEx. (check version!)
  • Fixed cellCameraIsAvailable.
  • Fixed data races.
  • Added missing nullptr check in cellCameraGetBufferInfo.
  • Simplify common error checking.
  • Simplify read attribute.
  • Simplify and atomic-ize cellCamera state management.

This pull request is also needed for savestates.

@elad335
Copy link
Contributor Author

elad335 commented Sep 4, 2021

Wait with merging, I need some more cleanup in cellCamera.

@elad335 elad335 changed the title cellCamera: Remove read_mode variable cellCamera: Some Refactoring Sep 4, 2021
@elad335 elad335 changed the title cellCamera: Some Refactoring cellCamera: Improvements and refactoring Sep 5, 2021
@elad335
Copy link
Contributor Author

elad335 commented Sep 5, 2021

  • Fixed cellCameraEnd memleak.
  • Fixed many error checks of null handler.
  • Fixed cellCameraGetBufferSize. (override width/height, not bytesize)
  • Fixed cellCameraIsAttached, remove hacks!
  • Fixed cellCameraOpenEx. (check version!)
  • Fixed cellCameraIsAvailable.
  • Fixed data races.
  • Simplify common error checking.
  • Simplify and atomic-ize cellCamera state management.

rpcs3/Emu/Cell/Modules/cellCamera.cpp Outdated Show resolved Hide resolved
rpcs3/Emu/Cell/Modules/cellCamera.cpp Outdated Show resolved Hide resolved
rpcs3/Emu/Cell/Modules/cellCamera.cpp Outdated Show resolved Hide resolved

switch (state)
{
case camera_state::detached: return not_an_error(CELL_CAMERA_ERROR_DEVICE_NOT_FOUND);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is is this notanerror

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's a null handler error.

rpcs3/Emu/Cell/Modules/cellCamera.cpp Outdated Show resolved Hide resolved
@elad335 elad335 force-pushed the camera-fixup branch 3 times, most recently from 8fc2d30 to 469e6cd Compare September 7, 2021 07:17
}

if (func())
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of what you're doing here tbh.

  1. It never reaches this point if the camera state is correct. So it is only checked if the camera state is wrong anyway.
  2. It is kinda spaghetti code and hard to read in the flow of the functions
  3. It adds another abstraction that you need to wrap your head around if you try to match assembly to code for example

So I personally would prefer if this function stayed a state check, and the param checks would remain conventional.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see the ordering bug, will fix.
Although it packs common logic which in return reduces amount of LOC significantly. IMO it should be better documented as an optional ""optimization"" for code size. When this optimization cannot be followed one shall return to the manual coding of checks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the attempt to reduce LOC.
But i think in this case it's not really necessary, especially since it meddles with history as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And it makes this PR harder to review as well 💩

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main reason I'm modifying it in the first place is to remove unneeded variables for savestates (better to remove before PR is merged), history will be modified either way.
Everything in addition is a bonus.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm maybe I can unwrap it relatively easily.

@elad335
Copy link
Contributor Author

elad335 commented Sep 15, 2021

Fixed review comments.

* Fixed cellCameraEnd memleak.
* Fixed many error checks of null handler.
* Fixed cellCameraGetBufferSize. (override width/height, not bytesize)
* Fixed cellCameraIsAttached, remove hacks!
* Fixed cellCameraOpenEx. (check version!)
* Fixed cellCameraIsAvailable.
* Added nullptr check in cellCameraGetBufferInfo.
* Simplify common error checking.
* Simplify and atomic-ize cellCamera state management.
@Megamouse
Copy link
Contributor

Can you remove the check_errors function for now?
It changes too much of the code so I can't really compare this with my own findings.

@Megamouse
Copy link
Contributor

This is now very outdated

@elad335
Copy link
Contributor Author

elad335 commented Sep 21, 2022

I don't even remember what it does, rip.

@elad335 elad335 closed this Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants