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

[WIP][pre-ll] better dx11 resize support, gamma port #1565

Closed
wants to merge 1 commit into from

Conversation

kvark
Copy link
Member

@kvark kvark commented Oct 12, 2017

Findings on the way to #1564
RFC!
cc @Bastacyclop @zakorgy

@@ -50,21 +56,46 @@ const CLEAR_COLOR: [f32; 4] = [0.5, 0.5, 0.5, 1.0];

type SurfaceData = <<ColorFormat as Formatted>::Surface as SurfaceTyped>::DataType;

enum Backend {
#[cfg(not(target_os = "windows"))]
Gl(glutin::GlWindow, gfx::handle::DepthStencilView<gfx_window_glutin::Resources, DepthFormat>),
Copy link
Contributor

Choose a reason for hiding this comment

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

gfx_window_glutin::Resources does not exist, although it could be a reexport of gfx_device_gl::Resources.

Copy link
Member Author

Choose a reason for hiding this comment

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

right, should be fixed now

@@ -50,21 +56,46 @@ const CLEAR_COLOR: [f32; 4] = [0.5, 0.5, 0.5, 1.0];

type SurfaceData = <<ColorFormat as Formatted>::Surface as SurfaceTyped>::DataType;

enum Backend {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why use a single variant enum instead of a tuple struct ?

Copy link
Member Author

Choose a reason for hiding this comment

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

that came from my original attempt to make it a run-time switch. Fixed now

pipe::new()
).unwrap();

let (mut backend, mut device, mut factory, pso, main_color) = match () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use {} instead of match () { _ => {} } ?

Copy link
Member Author

Choose a reason for hiding this comment

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

{} in expressions is not allowed, and copying the whole starting line for both cases would be unfortunate

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you could use if cfg! together with else?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah the code won't compile, sorry.

},
Err(e) => error!("Resize failed: {}", e),
}
//TODO: clean up the old references first!
Copy link
Contributor

Choose a reason for hiding this comment

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

How do you plan to do that ? Some interior mutability might enable the DX11 backend to update the existing reference or to invalidate it. Another possibility could be to have some kind of generation id to avoid reference mutation while still invalidating it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, good ideas!
It's not a big priority for me now to make this work universally on Dx11. The client doesn't use gfx_app, they just need a way to read back textures.

use core::Factory;
// first, replace the main view pointer with a dummy
// the code assumes this is the last standing reference, beware!
*main_color = factory.create_render_target(1, 1).unwrap().2;
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 sure what's the purpose of this dummy target ? Looking at #1122 makes me believe that it's meant to propagate it to the application resize handling, which is not possible at this crate level. You could drop the given handle and return a new one ?

Copy link
Member Author

Choose a reason for hiding this comment

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

You could drop the given handle and return a new one ?

dropping is fine, but then you'd have to do some magic to prevent a double drop when the new one needs to overwrite the old one.
I chose the simplest approach here - overwrite the handle with a dummy target temporarily, so that the old one is freed.

Copy link
Member Author

@kvark kvark left a comment

Choose a reason for hiding this comment

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

@Bastacyclop thanks for thoughtful review!

@@ -50,21 +56,46 @@ const CLEAR_COLOR: [f32; 4] = [0.5, 0.5, 0.5, 1.0];

type SurfaceData = <<ColorFormat as Formatted>::Surface as SurfaceTyped>::DataType;

enum Backend {
Copy link
Member Author

Choose a reason for hiding this comment

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

that came from my original attempt to make it a run-time switch. Fixed now

@@ -50,21 +56,46 @@ const CLEAR_COLOR: [f32; 4] = [0.5, 0.5, 0.5, 1.0];

type SurfaceData = <<ColorFormat as Formatted>::Surface as SurfaceTyped>::DataType;

enum Backend {
#[cfg(not(target_os = "windows"))]
Gl(glutin::GlWindow, gfx::handle::DepthStencilView<gfx_window_glutin::Resources, DepthFormat>),
Copy link
Member Author

Choose a reason for hiding this comment

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

right, should be fixed now

pipe::new()
).unwrap();

let (mut backend, mut device, mut factory, pso, main_color) = match () {
Copy link
Member Author

Choose a reason for hiding this comment

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

{} in expressions is not allowed, and copying the whole starting line for both cases would be unfortunate

},
Err(e) => error!("Resize failed: {}", e),
}
//TODO: clean up the old references first!
Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, good ideas!
It's not a big priority for me now to make this work universally on Dx11. The client doesn't use gfx_app, they just need a way to read back textures.

use core::Factory;
// first, replace the main view pointer with a dummy
// the code assumes this is the last standing reference, beware!
*main_color = factory.create_render_target(1, 1).unwrap().2;
Copy link
Member Author

Choose a reason for hiding this comment

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

You could drop the given handle and return a new one ?

dropping is fine, but then you'd have to do some magic to prevent a double drop when the new one needs to overwrite the old one.
I chose the simplest approach here - overwrite the handle with a dummy target temporarily, so that the old one is freed.

@Skepfyr Skepfyr mentioned this pull request Apr 16, 2018
63 tasks
@msiglreith
Copy link
Contributor

Shall we close this one?

@kvark
Copy link
Member Author

kvark commented Jun 4, 2018

Yeah... there has been a few hours put into this that I'd not like to see wasted, but nobody is interested in the outcome atm, so no need to leave it hanging here.

@kvark kvark closed this Jun 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants