I need to monitor my app GPU usage. I'm able to do it on nvidia cards (with GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX) but i can't achieve it with ATI card.
I tried with the GL_ATI_meminfo but it's not available on my platform. I tried with WGL_AMD_gpu_association but I can only retrieve the card memory, not the current used/free value...
When i run an app like processExplorer I can see the value that i'm looking.
Does someone know how to do it?
Here's all available extensions on my platform:
GL_AMDX_debug_output
GL_AMD_blend_minmax_factor
GL_AMD_conservative_depth
GL_AMD_debug_output
GL_AMD_depth_clamp_separate
GL_AMD_draw_buffers_blend
GL_AMD_framebuffer_sample_positions
GL_AMD_gcn_shader
GL_AMD_gpu_shader_int64
GL_AMD_interleaved_elements
GL_AMD_multi_draw_indirect
GL_AMD_name_gen_delete
GL_AMD_performance_monitor
GL_AMD_pinned_memory
GL_AMD_query_buffer_object
GL_AMD_sample_positions
GL_AMD_seamless_cubemap_per_texture
GL_AMD_shader_atomic_counter_ops
GL_AMD_shader_stencil_export
GL_AMD_shader_stencil_value_export
GL_AMD_shader_trace
GL_AMD_shader_trinary_minmax
GL_AMD_sparse_texture
GL_AMD_stencil_operation_extended
GL_AMD_texture_cube_map_array
GL_AMD_texture_texture4
GL_AMD_transform_feedback3_lines_triangles
GL_AMD_transform_feedback4
GL_AMD_vertex_shader_layer
GL_AMD_vertex_shader_viewport_index
GL_ARB_ES2_compatibility
GL_ARB_ES3_1_compatibility
GL_ARB_ES3_compatibility
GL_ARB_arrays_of_arrays
GL_ARB_base_instance
GL_ARB_bindless_texture
GL_ARB_blend_func_extended
GL_ARB_buffer_storage
GL_ARB_clear_buffer_object
GL_ARB_clear_texture
GL_ARB_clip_control
GL_ARB_color_buffer_float
GL_ARB_compressed_texture_pixel_storage
GL_ARB_compute_shader
GL_ARB_conditional_render_inverted
GL_ARB_conservative_depth
GL_ARB_copy_buffer
GL_ARB_copy_image
GL_ARB_cull_distance
GL_ARB_debug_output
GL_ARB_depth_buffer_float
GL_ARB_depth_clamp
GL_ARB_depth_texture
GL_ARB_derivative_control
GL_ARB_direct_state_access
GL_ARB_draw_buffers
GL_ARB_draw_buffers_blend
GL_ARB_draw_elements_base_vertex
GL_ARB_draw_indirect
GL_ARB_draw_instanced
GL_ARB_enhanced_layouts
GL_ARB_explicit_attrib_location
GL_ARB_explicit_uniform_location
GL_ARB_fragment_coord_conventions
GL_ARB_fragment_layer_viewport
GL_ARB_fragment_program
GL_ARB_fragment_program_shadow
GL_ARB_fragment_shader
GL_ARB_framebuffer_no_attachments
GL_ARB_framebuffer_object
GL_ARB_framebuffer_sRGB
GL_ARB_geometry_shader4
GL_ARB_get_program_binary
GL_ARB_get_texture_sub_image
GL_ARB_gl_spirv
GL_ARB_gpu_shader5
GL_ARB_gpu_shader_fp64
GL_ARB_half_float_pixel
GL_ARB_half_float_vertex
GL_ARB_imaging
GL_ARB_indirect_parameters
GL_ARB_instanced_arrays
GL_ARB_internalformat_query
GL_ARB_internalformat_query2
GL_ARB_invalidate_subdata
GL_ARB_map_buffer_alignment
GL_ARB_map_buffer_range
GL_ARB_multi_bind
GL_ARB_multi_draw_indirect
GL_ARB_multisample
GL_ARB_multitexture
GL_ARB_occlusion_query
GL_ARB_occlusion_query2
GL_ARB_parallel_shader_compile
GL_ARB_pipeline_statistics_query
GL_ARB_pixel_buffer_object
GL_ARB_point_parameters
GL_ARB_point_sprite
GL_ARB_program_interface_query
GL_ARB_provoking_vertex
GL_ARB_query_buffer_object
GL_ARB_robust_buffer_access_behavior
GL_ARB_sample_shading
GL_ARB_sampler_objects
GL_ARB_seamless_cube_map
GL_ARB_seamless_cubemap_per_texture
GL_ARB_separate_shader_objects
GL_ARB_shader_atomic_counters
GL_ARB_shader_ballot
GL_ARB_shader_bit_encoding
GL_ARB_shader_draw_parameters
GL_ARB_shader_group_vote
GL_ARB_shader_image_load_store
GL_ARB_shader_image_size
GL_ARB_shader_objects
GL_ARB_shader_precision
GL_ARB_shader_stencil_export
GL_ARB_shader_storage_buffer_object
GL_ARB_shader_subroutine
GL_ARB_shader_texture_image_samples
GL_ARB_shader_texture_lod
GL_ARB_shader_viewport_layer_array
GL_ARB_shading_language_100
GL_ARB_shading_language_420pack
GL_ARB_shading_language_packing
GL_ARB_shadow
GL_ARB_shadow_ambient
GL_ARB_sparse_buffer
GL_ARB_sparse_texture
GL_ARB_spirv_extensions
GL_ARB_stencil_texturing
GL_ARB_sync
GL_ARB_tessellation_shader
GL_ARB_texture_barrier
GL_ARB_texture_border_clamp
GL_ARB_texture_buffer_object
GL_ARB_texture_buffer_object_rgb32
GL_ARB_texture_buffer_range
GL_ARB_texture_compression
GL_ARB_texture_compression_bptc
GL_ARB_texture_compression_rgtc
GL_ARB_texture_cube_map
GL_ARB_texture_cube_map_array
GL_ARB_texture_env_add
GL_ARB_texture_env_combine
GL_ARB_texture_env_crossbar
GL_ARB_texture_env_dot3
GL_ARB_texture_float
GL_ARB_texture_gather
GL_ARB_texture_mirror_clamp_to_edge
GL_ARB_texture_mirrored_repeat
GL_ARB_texture_multisample
GL_ARB_texture_non_power_of_two
GL_ARB_texture_query_levels
GL_ARB_texture_query_lod
GL_ARB_texture_rectangle
GL_ARB_texture_rg
GL_ARB_texture_rgb10_a2ui
GL_ARB_texture_snorm
GL_ARB_texture_stencil8
GL_ARB_texture_storage
GL_ARB_texture_storage_multisample
GL_ARB_texture_swizzle
GL_ARB_texture_view
GL_ARB_timer_query
GL_ARB_transform_feedback2
GL_ARB_transform_feedback3
GL_ARB_transform_feedback_instanced
GL_ARB_transform_feedback_overflow_query
GL_ARB_transpose_matrix
GL_ARB_uniform_buffer_object
GL_ARB_vertex_array_bgra
GL_ARB_vertex_array_object
GL_ARB_vertex_attrib_64bit
GL_ARB_vertex_attrib_binding
GL_ARB_vertex_buffer_object
GL_ARB_vertex_program
GL_ARB_vertex_shader
GL_ARB_vertex_type_10f_11f_11f_rev
GL_ARB_vertex_type_2_10_10_10_rev
GL_ARB_viewport_array
GL_ARB_window_pos
GL_ATI_draw_buffers
GL_ATI_envmap_bumpmap
GL_ATI_fragment_shader
GL_ATI_separate_stencil
GL_ATI_texture_compression_3dc
GL_ATI_texture_env_combine3
GL_ATI_texture_float
GL_ATI_texture_mirror_once
GL_EXT_abgr
GL_EXT_bgra
GL_EXT_bindable_uniform
GL_EXT_blend_color
GL_EXT_blend_equation_separate
GL_EXT_blend_func_separate
GL_EXT_blend_minmax
GL_EXT_blend_subtract
GL_EXT_compiled_vertex_array
GL_EXT_copy_buffer
GL_EXT_copy_texture
GL_EXT_depth_bounds_test
GL_EXT_direct_state_access
GL_EXT_draw_buffers2
GL_EXT_draw_instanced
GL_EXT_draw_range_elements
GL_EXT_fog_coord
GL_EXT_framebuffer_blit
GL_EXT_framebuffer_multisample
GL_EXT_framebuffer_object
GL_EXT_framebuffer_sRGB
GL_EXT_geometry_shader4
GL_EXT_gpu_program_parameters
GL_EXT_gpu_shader4
GL_EXT_histogram
GL_EXT_multi_draw_arrays
GL_EXT_packed_depth_stencil
GL_EXT_packed_float
GL_EXT_packed_pixels
GL_EXT_pixel_buffer_object
GL_EXT_point_parameters
GL_EXT_polygon_offset_clamp
GL_EXT_provoking_vertex
GL_EXT_rescale_normal
GL_EXT_secondary_color
GL_EXT_separate_specular_color
GL_EXT_shader_image_load_store
GL_EXT_shader_integer_mix
GL_EXT_shadow_funcs
GL_EXT_stencil_wrap
GL_EXT_subtexture
GL_EXT_texgen_reflection
GL_EXT_texture3D
GL_EXT_texture_array
GL_EXT_texture_buffer_object
GL_EXT_texture_compression_bptc
GL_EXT_texture_compression_latc
GL_EXT_texture_compression_rgtc
GL_EXT_texture_compression_s3tc
GL_EXT_texture_cube_map
GL_EXT_texture_edge_clamp
GL_EXT_texture_env_add
GL_EXT_texture_env_combine
GL_EXT_texture_env_dot3
GL_EXT_texture_filter_anisotropic
GL_EXT_texture_integer
GL_EXT_texture_lod
GL_EXT_texture_lod_bias
GL_EXT_texture_mirror_clamp
GL_EXT_texture_object
GL_EXT_texture_rectangle
GL_EXT_texture_sRGB
GL_EXT_texture_sRGB_decode
GL_EXT_texture_shared_exponent
GL_EXT_texture_snorm
GL_EXT_texture_storage
GL_EXT_texture_swizzle
GL_EXT_timer_query
GL_EXT_transform_feedback
GL_EXT_vertex_array
GL_EXT_vertex_array_bgra
GL_EXT_vertex_attrib_64bit
GL_IBM_texture_mirrored_repeat
GL_INTEL_fragment_shader_ordering
GL_KHR_context_flush_control
GL_KHR_debug
GL_KHR_no_error
GL_KHR_parallel_shader_compile
GL_KHR_robust_buffer_access_behavior
GL_KHR_robustness
GL_KTX_buffer_region
GL_NV_alpha_to_coverage_dither_control
GL_NV_blend_square
GL_NV_conditional_render
GL_NV_copy_depth_to_color
GL_NV_copy_image
GL_NV_depth_buffer_float
GL_NV_explicit_multisample
GL_NV_float_buffer
GL_NV_half_float
GL_NV_primitive_restart
GL_NV_texgen_reflection
GL_NV_texture_barrier
GL_OES_EGL_image
GL_SGIS_generate_mipmap
GL_SGIS_texture_edge_clamp
GL_SGIS_texture_lod
GL_SUN_multi_draw_arrays
GL_WIN_swap_hint
WGL_EXT_swap_control
Please use Amd Display Library overdrive API 6.
https://github.com/GPUOpen-LibrariesAndSDKs/display-library
In the samples there you can see usage for ADL_Overdrive5_CurrentActivity_Get.
Related
I am working on a tool to use GL to render frames from a video onto a texture-mapped mesh. I already have a GL app working with a single image (PNG). Now I am trying to use gstreamer to decode the video.
I started with the appsink example.
I have gotten as far as piping the decoded video through glupload into an appsink. Now I need to convert the BufferRef I get from appsink.pull_sample().get_buffer() into a GL texture id (a u32) so I can pass it to GL functions like gl::BindTexture(gl::TEXTURE_2D, tex). I used set_caps() on the appsink to ensure the buffer has feature memory:GLMemory, so it better be a texture and not off-GPU.
How do I extract a GL texture id from a BufferRef using Rust's gstreamer and gstreamer-* crates?
Retrieving the texture from a GstGLMemory in C requires mapping the GstGLMemory itself with a special GST_MAP_GL flag. That specific interface for mapping an OpenGL texture does not currently have an analogue in rust yet. There is some work in a related area within https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/581 to help improve the situation with GStreamer OpenGL usage in rust.
If you only need readable access to the texture, there is an extension trait VideoFrameGLExt on VideoFrame that can get you access to the OpenGL texture. There is a usage of VideoFrameGLExt in the glupload example in the gstreamer-rs repository available from https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/blob/master/examples/src/bin/glupload.rs. The VideoFrameGLExt trait is currently implemented within https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/blob/master/gstreamer-gl/src/gl_video_frame.rs
Something like the following should work for read-only access:
// buffer: gst::Buffer
// info: gst::VideoInfo
if let Ok(frame) = gst_video::VideoFrame::from_buffer_readable_gl(buffer, &info) {
if let Some(texture) = frame.get_texture_id(0) {
// use texture somehow
}
}
If instead you also need to write to the texture, that is currently not exposed and manual bindings would need to be written.
The code I eventually got working was
fn get_gl_memory(bref: &BufferRef, idx: u32) -> Option<*mut GstGLMemory> {
unsafe {
let n = gst_sys::gst_buffer_n_memory(bref.as_ptr() as *mut _);
if idx >= n {
return None;
}
let mem = gst_sys::gst_buffer_peek_memory(bref.as_ptr() as *mut _, idx);
if 0 != gst_gl_sys::gst_is_gl_memory(mem) {
Some(mem as *mut _)
} else {
None
}
}
}
//
let gl_mem = get_gl_memory(buffer, 0).unwrap();
let gl_mem = unsafe { &*gl_mem };
let tex_id = gl_mem.tex_id;
although the solution from ystreet00 works great if you have convenient access to the gst::VideoInfo.
I tried to use the simple example provided here:
https://learn.microsoft.com/en-us/dotnet/api/xamarin.forms.openglview?view=xamarin-forms
to try to create a XAML View with the OpenGLView Class. But I'm running into issues. This is Xamarin.Forms (l, ran on iOS Simulator and using the Prism framework, macOS Mojave and Visual Studio for Mac 2019 Pro.
Here is my XAML Code:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
xmlns:otk="clr-namespace:OpenTK.Graphics.ES3"
x:Class="MyApp.Views.OpenGlPage">
<StackLayout HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand">
<OpenGLView x:Name="openGLView" HasRenderLoop="true"/>
<Button Command="{Binding Display}" Text="Display"/>
</StackLayout>
</ContentPage>
and the code behind
using Xamarin.Forms;
using OpenTK.Graphics.ES30;
namespace MyApp.Views
{
public partial class OpenGlPage : ContentPage
{
float red, green, blue;
public OpenGlPage()
{
InitializeComponent();
Title = "OpenGL";
openGLView.HeightRequest = 300;
openGLView.WidthRequest = 300;
openGLView.OnDisplay = r => {
GL.ClearColor(red, green, blue, 1.0f);
GL.Clear((ClearBufferMask.ColorBufferBit |
ClearBufferMask.DepthBufferBit));
red += 0.01f;
if (red >= 1.0f)
red -= 1.0f;
green += 0.02f;
if (green >= 1.0f)
green -= 1.0f;
blue += 0.03f;
if (blue >= 1.0f)
blue -= 1.0f;
};
}
}
}
The ViewModel does not have much, and the View is properly registered with Prism so the navigating to this view works fine.
But it looks like there is some issue with the way that OpenGL is used or initialized when dropped in XAML like this. When the execution hits any GL.* call application crashes. This is the error:
=================================================================
Native Crash Reporting
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
=================================================================
Basic Fault Adddress Reporting
=================================================================
instruction pointer is NULL, skip dumping
=================================================================
Native stacktrace:
=================================================================
0x10184704d - /Users/user/Library/Developer/CoreSimulator/Devices/602074EE-E100-4319-B9DE-D9460B6264EB/data/Containers/Bundle/Application/7937567A-2C4D-43A6-8A81-B27BFEF73EF6/Prism1.iOS.app/Prism1.iOS : mono_dump_native_crash_info
0x10183b7a5 - /Users/user/Library/Developer/CoreSimulator/Devices/602074EE-E100-4319-B9DE-D9460B6264EB/data/Containers/Bundle/Application/7937567A-2C4D-43A6-8A81-B27BFEF73EF6/Prism1.iOS.app/Prism1.iOS : mono_handle_native_crash
0x10184db43 - /Users/user/Library/Developer/CoreSimulator/Devices/602074EE-E100-4319-B9DE-D9460B6264EB/data/Containers/Bundle/Application/7937567A-2C4D-43A6-8A81-B27BFEF73EF6/Prism1.iOS.app/Prism1.iOS : mono_sigsegv_signal_handler
0x10f329b5d - /usr/lib/system/libsystem_platform.dylib : _sigtramp
0x18 - Unknown
0x135d884bf - Unknown
0x135d88927 - Unknown
0x101850fa1 - /Users/user/Library/Developer/CoreSimulator/Devices/602074EE-E100-4319-B9DE-D9460B6264EB/data/Containers/Bundle/Application/7937567A-2C4D-43A6-8A81-B27BFEF73EF6/Prism1.iOS.app/Prism1.iOS : mono_jit_runtime_invoke
0x10196ab78 - /Users/user/Library/Developer/CoreSimulator/Devices/602074EE-E100-4319-B9DE-D9460B6264EB/data/Containers/Bundle/Application/7937567A-2C4D-43A6-8A81-B27BFEF73EF6/Prism1.iOS.app/Prism1.iOS : mono_runtime_invoke_checked
0x10196e4ce - /Users/user/Library/Developer/CoreSimulator/Devices/602074EE-E100-4319-B9DE-D9460B6264EB/data/Containers/Bundle/Application/7937567A-2C4D-43A6-8A81-B27BFEF73EF6/Prism1.iOS.app/Prism1.iOS : mono_runtime_invoke
0x101a8142a - /Users/user/Library/Developer/CoreSimulator/Devices/602074EE-E100-4319-B9DE-D9460B6264EB/data/Containers/Bundle/Application/7937567A-2C4D-43A6-8A81-B27BFEF73EF6/Prism1.iOS.app/Prism1.iOS : xamarin_invoke_trampoline
0x101a89365 - /Users/user/Library/Developer/CoreSimulator/Devices/602074EE-E100-4319-B9DE-D9460B6264EB/data/Containers/Bundle/Application/7937567A-2C4D-43A6-8A81-B27BFEF73EF6/Prism1.iOS.app/Prism1.iOS : xamarin_arch_trampoline
0x101a8a761 - /Users/user/Library/Developer/CoreSimulator/Devices/602074EE-E100-4319-B9DE-D9460B6264EB/data/Containers/Bundle/Application/7937567A-2C4D-43A6-8A81-B27BFEF73EF6/Prism1.iOS.app/Prism1.iOS : xamarin_x86_64_common_trampoline
0x1077a8ffd - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/GLKit.framework/GLKit : -[GLKView _display:]
0x112231c21 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/QuartzCore.framework/QuartzCore : -[CALayer display]
0x112244003 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/QuartzCore.framework/QuartzCore : _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE
0x1121b33aa - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/QuartzCore.framework/QuartzCore : _ZN2CA7Context18commit_transactionEPNS_11TransactionE
0x1121ea584 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/QuartzCore.framework/QuartzCore : _ZN2CA11Transaction6commitEv
0x117924d8a - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : _UIApplicationFlushRunLoopCATransactionIfTooLate
0x117a17f5f - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : __handleEventQueueInternal
0x10242ebe1 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
0x10242e463 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : __CFRunLoopDoSources0
0x102428b1f - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : __CFRunLoopRun
0x102428302 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : CFRunLoopRunSpecific
0x11249f2fe - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices : GSEventRunModal
0x11792aba2 - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : UIApplicationMain
0x134910932 - Unknown
0x1349106c3 - Unknown
=================================================================
Managed Stacktrace:
=================================================================
at <unknown> <0xffffffff>
at UIKit.UIApplication:UIApplicationMain <0x00211>
at UIKit.UIApplication:Main <0x000b2>
at UIKit.UIApplication:Main <0x00222>
at Prism1.iOS.Application:Main <0x00092>
at <Module>:runtime_invoke_void_object <0x00168>
=================================================================
This happens regardless what GL call I have there in the OnDisplay handler. If I remove the GL calls everything works fine of course, minus the OpenGL content :)
Compilation warnings:
I initialize my QCRenderer like this:
let glPFAttributes:[NSOpenGLPixelFormatAttribute] = [
UInt32(NSOpenGLPFABackingStore),
UInt32(0)
]
let glPixelFormat = NSOpenGLPixelFormat(attributes: glPFAttributes)
if glPixelFormat == nil {
println("Pixel Format is nil")
return
}
let openGLView = NSOpenGLView(frame: glSize, pixelFormat: glPixelFormat)
let openGLContext = NSOpenGLContext(format: glPixelFormat, shareContext: nil)
let qcRenderer = QCRenderer(openGLContext: openGLContext, pixelFormat: glPixelFormat, file: compositionPath)
Further down in the code, I call renderAtTime like this:
if !qcRenderer.renderAtTime(frameTime, arguments: nil) {
println("Rendering failed at \(frameTime)s.")
return
}
which always produces this error message:
2014-10-30 15:30:50.976 HQuartzRenderer[3996:692255] *** Message from <QCClear = 0x100530590 "Clear_1">:
OpenGL error 0x0506 (invalid framebuffer operation)
2014-10-30 15:30:50.976 HQuartzRenderer[3996:692255] *** Message from <QCClear = 0x100530590 "Clear_1">:
Execution failed at time 0.000
2014-10-30 15:30:50.976 HQuartzRenderer[3996:692255] *** Message from <QCPatch = 0x100547860 "(null)">:
Execution failed at time 0.000
Rendering failed at 0.0s.
The Quartz Composition is just a simple GLSL shader which runs just fine in Quartz Composer.
Here's a screenshot of the Quartz Composer window:
There's not much on the internet on this that I could find. I hope someone here knows something that might help.
By the way, I know that I could just initialize the QCRenderer like
let qcRenderer = QCRenderer(offScreenWithSize: size, colorSpace: CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB), composition: qcComposition)
but I want to take advantage of my GPU's multisampling capabilities to get an antialiased image. That's gotta be more performant than rendering at 4x size, then manually downsizing the image.
Edit: Changed pixel format to
let glPFAttributes:[NSOpenGLPixelFormatAttribute] = [
UInt32(NSOpenGLPFAAccelerated),
UInt32(NSOpenGLPFADoubleBuffer),
UInt32(NSOpenGLPFANoRecovery),
UInt32(NSOpenGLPFABackingStore),
UInt32(NSOpenGLPFAColorSize), UInt32(128),
UInt32(NSOpenGLPFADepthSize), UInt32(24),
UInt32(NSOpenGLPFAOpenGLProfile),
UInt32(NSOpenGLProfileVersion3_2Core),
UInt32(0)
]
I'm trying to define a simple SamplerState in an HLSL file to use for textures.
When compiling the shader, I get an error:
error X3004: undeclared identifier 'Filter'
Source:
// part of render.hlsl
SamplerState linear_sample=
{
Filter=MIN_MAG_MIP_LINEAR;
AddressU = Wrap;
AddressV = Wrap;
};
Compilation:
hr=D3DX10CreateEffectFromFile("render.hlsl",NULL,NULL,"fx_4_0",D3D10_SHADER_ENABLE_STRICTNESS | D3D10_SHADER_DEBUG,0,dx_device,NULL,NULL,&dx_effect,&dx_err,NULL);'
I've checked on MSDN, and nothing appears to be wrong with my HLSL file. Am I compiling incorrectly?
Remove the = sign after linear_sample.
I can create a ID2D1RenderTarget for a IWICBitmap using the following code...
D2D1_FACTORY_OPTIONS options;
ZeroMemory(&options, sizeof(D2D1_FACTORY_OPTIONS));
#if defined(_DEBUG)
// If the project is in a debug build, enable Direct2D debugging via SDK Layers
options.debugLevel = D2D1_DEBUG_LEVEL_INFORMATION;
#endif
ThrowIfFailed(D2D1CreateFactory(
D2D1_FACTORY_TYPE_SINGLE_THREADED,
__uuidof(ID2D1Factory1),
&options,
&m_d2dFactory
));
D2D1_RENDER_TARGET_PROPERTIES props;
props = D2D1::RenderTargetProperties();
m_d2dFactory->CreateWicBitmapRenderTarget(m_pTheBitmap.Get(), &props, &m_target);
But if I want to apply ID2D1Effect to this bitmap, I can do that only if I have ID2D1DeviceContext. How do I get a ID2D1DeviceContext for a IWICBitmap?
Once you have the render target created, you need to QI to the ID2D1DeviceContext. e.g.
pWicRenderTarget->QueryInterface(
__uuidof(ID2D1DeviceContext),
reinterpret_cast<void**>(&pDC)
);
Remember that the QI is increasing the ref count as well.