@@ -4,9 +4,8 @@ use crate::ctypes::{
4
4
use crate :: error:: { assert_non_null, assert_some_ptr, LibrashaderError } ;
5
5
use crate :: ffi:: extern_fn;
6
6
use crate :: LIBRASHADER_API_VERSION ;
7
- use librashader:: runtime:: gl:: error:: FilterChainError ;
8
7
use librashader:: runtime:: gl:: {
9
- FilterChain , FilterChainOptions , FrameOptions , GLFramebuffer , GLImage ,
8
+ FilterChain , FilterChainOptions , FrameOptions , GLImage ,
10
9
} ;
11
10
use librashader:: runtime:: FilterChainParameters ;
12
11
use librashader:: runtime:: { Size , Viewport } ;
@@ -21,36 +20,21 @@ use std::sync::Arc;
21
20
/// A GL function loader that librashader needs to be initialized with.
22
21
pub type libra_gl_loader_t = unsafe extern "system" fn ( * const c_char ) -> * const c_void ;
23
22
24
- /// OpenGL parameters for the source image.
23
+ /// OpenGL parameters for an image.
25
24
#[ repr( C ) ]
26
- pub struct libra_source_image_gl_t {
27
- /// A texture GLuint to the source image .
25
+ pub struct libra_image_gl_t {
26
+ /// A texture GLuint to the texture .
28
27
pub handle : u32 ,
29
- /// The format of the source image .
28
+ /// The format of the texture .
30
29
pub format : u32 ,
31
- /// The width of the source image .
30
+ /// The width of the texture .
32
31
pub width : u32 ,
33
- /// The height of the source image .
32
+ /// The height of the texture .
34
33
pub height : u32 ,
35
34
}
36
35
37
- /// OpenGL parameters for the output framebuffer.
38
- #[ repr( C ) ]
39
- pub struct libra_output_framebuffer_gl_t {
40
- /// A framebuffer GLuint to the output framebuffer.
41
- pub fbo : u32 ,
42
- /// A texture GLuint to the logical buffer of the output framebuffer.
43
- pub texture : u32 ,
44
- /// The format of the output framebuffer.
45
- pub format : u32 ,
46
- /// The width of the output image.
47
- pub width : u32 ,
48
- /// The height of the output image.
49
- pub height : u32 ,
50
- }
51
-
52
- impl From < libra_source_image_gl_t > for GLImage {
53
- fn from ( value : libra_source_image_gl_t ) -> Self {
36
+ impl From < libra_image_gl_t > for GLImage {
37
+ fn from ( value : libra_image_gl_t ) -> Self {
54
38
let handle = NonZeroU32 :: try_from ( value. handle )
55
39
. ok ( )
56
40
. map ( glow:: NativeTexture ) ;
@@ -166,7 +150,7 @@ extern_fn! {
166
150
///
167
151
/// - `chain` is a handle to the filter chain.
168
152
/// - `frame_count` is the number of frames passed to the shader
169
- /// - `image` is a `libra_source_image_gl_t `, containing the name of a Texture, format, and size information to
153
+ /// - `image` is a `libra_image_gl_t `, containing the name of a Texture, format, and size information to
170
154
/// to an image that will serve as the source image for the frame.
171
155
/// - `out` is a `libra_output_framebuffer_gl_t`, containing the name of a Framebuffer, the name of a Texture, format,
172
156
/// and size information for the render target of the frame.
@@ -193,14 +177,16 @@ extern_fn! {
193
177
nopanic fn libra_gl_filter_chain_frame(
194
178
chain: * mut libra_gl_filter_chain_t,
195
179
frame_count: usize ,
196
- image: libra_source_image_gl_t ,
197
- out: libra_output_framebuffer_gl_t ,
180
+ image: libra_image_gl_t ,
181
+ out: libra_image_gl_t ,
198
182
viewport: * const libra_viewport_t,
199
183
mvp: * const f32 ,
200
184
opt: * const MaybeUninit <frame_gl_opt_t>,
201
185
) mut |chain| {
202
186
assert_some_ptr!( mut chain) ;
203
187
let image: GLImage = image. into( ) ;
188
+ let out: GLImage = out. into( ) ;
189
+
204
190
let mvp = if mvp. is_null( ) {
205
191
None
206
192
} else {
@@ -214,26 +200,14 @@ extern_fn! {
214
200
215
201
let opt = opt. map( FromUninit :: from_uninit) ;
216
202
217
- let texture = NonZeroU32 :: try_from( out. texture)
218
- . ok( )
219
- . map( glow:: NativeTexture ) ;
220
-
221
- let fbo = NonZeroU32 :: try_from( out. fbo)
222
- . ok( )
223
- . map( glow:: NativeFramebuffer )
224
- . ok_or( FilterChainError :: GlInvalidFramebuffer ) ?;
225
-
226
- let framebuffer = GLFramebuffer :: new_from_raw( Arc :: clone( chain. get_context( ) ) ,
227
- texture, fbo, out. format, Size :: new( out. width, out. height) , 1 ) ;
228
-
229
203
let viewport = if viewport. is_null( ) {
230
- Viewport :: new_render_target_sized_origin( & framebuffer , mvp) ?
204
+ Viewport :: new_render_target_sized_origin( & out , mvp) ?
231
205
} else {
232
206
let viewport = unsafe { viewport. read( ) } ;
233
207
Viewport {
234
208
x: viewport. x,
235
209
y: viewport. y,
236
- output: & framebuffer ,
210
+ output: & out ,
237
211
size: Size {
238
212
height: viewport. height,
239
213
width: viewport. width
0 commit comments