@@ -948,6 +948,14 @@ _SOKOL_PRIVATE void _sgimgui_igsettooltip(const char* fmt, ...) {
948948 va_end (args );
949949}
950950
951+ _SOKOL_PRIVATE bool _sgimgui_igbegintooltip (void ) {
952+ return _SGIMGUI_IMGUI_FUNC (BeginTooltip )();
953+ }
954+
955+ _SOKOL_PRIVATE void _sgimgui_igendtooltip (void ) {
956+ _SGIMGUI_IMGUI_FUNC (EndTooltip )();
957+ }
958+
951959_SOKOL_PRIVATE bool _sgimgui_igsliderfloatex (const char * label , float * v , float v_min , float v_max , const char * format , ImGuiSliderFlags flags ) {
952960 #if defined(__cplusplus )
953961 return ImGui ::SliderFloat (label , v , v_min , v_max , format , flags );
@@ -3209,6 +3217,43 @@ _SOKOL_PRIVATE void _sgimgui_pop_debug_group(void* user_data) {
32093217}
32103218
32113219/*--- IMGUI HELPERS ----------------------------------------------------------*/
3220+ _SOKOL_PRIVATE void _sgimgui_draw_image (sgimgui_t * ctx , sg_image img , float * opt_scale_ptr , float max_width ) {
3221+ if (sg_query_image_state (img ) != SG_RESOURCESTATE_VALID ) {
3222+ _sgimgui_igtext ("Image not in valid state." );
3223+ return ;
3224+ }
3225+ // try to find a texture view for the image
3226+ sg_view view = {SG_INVALID_ID };
3227+ for (int i = 0 ; i < ctx -> view_window .num_slots ; i ++ ) {
3228+ const sgimgui_view_t * view_ui = & ctx -> view_window .slots [i ];
3229+ view = view_ui -> res_id ;
3230+ if (sg_query_view_type (view ) == SG_VIEWTYPE_TEXTURE ) {
3231+ sg_image view_img = sg_query_view_image (view );
3232+ if (view_img .id == img .id ) {
3233+ break ;
3234+ }
3235+ }
3236+ }
3237+ if (view .id != SG_INVALID_ID ) {
3238+ _sgimgui_igpushidint ((int )view .id );
3239+ float scale = 1.0f ;
3240+ if (opt_scale_ptr ) {
3241+ _sgimgui_igsliderfloatex ("Scale" , opt_scale_ptr , 0.125f , 8.0f , "%.3f" , ImGuiSliderFlags_Logarithmic );
3242+ scale = * opt_scale_ptr ;
3243+ }
3244+ float w = (float )sg_query_image_width (img ) * scale ;
3245+ float h = (float )sg_query_image_height (img ) * scale ;
3246+ if ((max_width > 1.0f ) && (w > max_width )) {
3247+ h *= max_width / w ;
3248+ w = max_width ;
3249+ }
3250+ _sgimgui_igimage (simgui_imtextureid (view ), IMVEC2 (w , h ));
3251+ _sgimgui_igpopid ();
3252+ } else {
3253+ _sgimgui_igtext ("Image has no texture view." , img .id );
3254+ }
3255+ }
3256+
32123257_SOKOL_PRIVATE bool _sgimgui_draw_resid_list_item (uint32_t res_id , const char * label , bool selected ) {
32133258 _sgimgui_igpushidint ((int )res_id );
32143259 bool res ;
@@ -3280,6 +3325,15 @@ _SOKOL_PRIVATE bool _sgimgui_draw_view_link(sgimgui_t* ctx, sg_view view) {
32803325 if (view .id != SG_INVALID_ID ) {
32813326 const sgimgui_view_t * view_ui = & ctx -> view_window .slots [_sgimgui_slot_index (view .id )];
32823327 retval = _sgimgui_draw_resid_link (5 , view .id , view_ui -> label .buf );
3328+ if (_sgimgui_igisitemhovered (0 )) {
3329+ sg_image img = sg_query_view_image (view );
3330+ if (img .id != SG_INVALID_ID ) {
3331+ if (_sgimgui_igbegintooltip ()) {
3332+ _sgimgui_draw_image (ctx , img , 0 , 128.0f );
3333+ _sgimgui_igendtooltip ();
3334+ }
3335+ }
3336+ }
32833337 }
32843338 return retval ;
32853339}
@@ -3470,35 +3524,6 @@ _SOKOL_PRIVATE void _sgimgui_draw_buffer_panel(sgimgui_t* ctx, sg_buffer buf) {
34703524 }
34713525}
34723526
3473- _SOKOL_PRIVATE void _sgimgui_draw_image (sgimgui_t * ctx , sg_image img , float * scale ) {
3474- if (sg_query_image_state (img ) != SG_RESOURCESTATE_VALID ) {
3475- _sgimgui_igtext ("Image not in valid state." );
3476- return ;
3477- }
3478- // try to find a texture view for the image
3479- sg_view view = {SG_INVALID_ID };
3480- for (int i = 0 ; i < ctx -> view_window .num_slots ; i ++ ) {
3481- const sgimgui_view_t * view_ui = & ctx -> view_window .slots [i ];
3482- view = view_ui -> res_id ;
3483- if (sg_query_view_type (view ) == SG_VIEWTYPE_TEXTURE ) {
3484- sg_image view_img = sg_query_view_image (view );
3485- if (view_img .id == img .id ) {
3486- break ;
3487- }
3488- }
3489- }
3490- if (view .id != SG_INVALID_ID ) {
3491- _sgimgui_igpushidint ((int )view .id );
3492- _sgimgui_igsliderfloatex ("Scale" , scale , 0.125f , 8.0f , "%.3f" , ImGuiSliderFlags_Logarithmic );
3493- float w = (float )sg_query_image_width (img ) * (* scale );
3494- float h = (float )sg_query_image_height (img ) * (* scale );
3495- _sgimgui_igimage (simgui_imtextureid (view ), IMVEC2 (w , h ));
3496- _sgimgui_igpopid ();
3497- } else {
3498- _sgimgui_igtext ("No valid texture view found for image 0x08X" , img .id );
3499- }
3500- }
3501-
35023527_SOKOL_PRIVATE void _sgimgui_draw_image_panel (sgimgui_t * ctx , sg_image img ) {
35033528 if (img .id != SG_INVALID_ID ) {
35043529 _sgimgui_igbeginchild ("image" , IMVEC2 (0 ,0 ), false, 0 );
@@ -3509,7 +3534,7 @@ _SOKOL_PRIVATE void _sgimgui_draw_image_panel(sgimgui_t* ctx, sg_image img) {
35093534 _sgimgui_igtext ("Label: %s" , img_ui -> label .buf [0 ] ? img_ui -> label .buf : "---" );
35103535 _sgimgui_draw_resource_slot (& info .slot );
35113536 _sgimgui_igseparator ();
3512- _sgimgui_draw_image (ctx , img , & img_ui -> ui_scale );
3537+ _sgimgui_draw_image (ctx , img , & img_ui -> ui_scale , 4096.0f );
35133538 _sgimgui_igseparator ();
35143539 _sgimgui_igtext ("Type: %s" , _sgimgui_imagetype_string (desc -> type ));
35153540 _sgimgui_igtext ("Usage:\n" );
@@ -3940,7 +3965,7 @@ _SOKOL_PRIVATE void _sgimgui_draw_image_view(sgimgui_t* ctx, const char* title,
39403965 _sgimgui_igtext (" Slice: %d" , desc -> slice );
39413966 _sgimgui_igseparator ();
39423967 sgimgui_view_t * view_ui = & ctx -> view_window .slots [_sgimgui_slot_index (view .id )];
3943- _sgimgui_draw_image (ctx , desc -> image , & view_ui -> ui_scale );
3968+ _sgimgui_draw_image (ctx , desc -> image , & view_ui -> ui_scale , 4096.0f );
39443969}
39453970
39463971_SOKOL_PRIVATE void _sgimgui_draw_texture_view (sgimgui_t * ctx , const char * title , sg_view view , const sg_texture_view_desc * desc ) {
@@ -3955,7 +3980,7 @@ _SOKOL_PRIVATE void _sgimgui_draw_texture_view(sgimgui_t* ctx, const char* title
39553980 _sgimgui_igtext (" Slices Count: %d" , desc -> slices .count );
39563981 _sgimgui_igseparator ();
39573982 sgimgui_view_t * view_ui = & ctx -> view_window .slots [_sgimgui_slot_index (view .id )];
3958- _sgimgui_draw_image (ctx , desc -> image , & view_ui -> ui_scale );
3983+ _sgimgui_draw_image (ctx , desc -> image , & view_ui -> ui_scale , 4096.0f );
39593984}
39603985
39613986_SOKOL_PRIVATE void _sgimgui_draw_view_panel (sgimgui_t * ctx , sg_view view ) {
@@ -4003,37 +4028,33 @@ _SOKOL_PRIVATE void _sgimgui_draw_bindings_panel(sgimgui_t* ctx, const sg_bindin
40034028 for (int i = 0 ; i < SG_MAX_VERTEXBUFFER_BINDSLOTS ; i ++ ) {
40044029 sg_buffer buf = bnd -> vertex_buffers [i ];
40054030 if (buf .id != SG_INVALID_ID ) {
4006- _sgimgui_igseparator ();
4007- _sgimgui_igtext ("Vertex Buffer Slot #%d:" , i );
4008- _sgimgui_igtext (" Buffer: " ); _sgimgui_igsameline ();
4031+ _sgimgui_igtext ("Vertex Buffer #%d:" , i ); _sgimgui_igsameline ();
40094032 if (_sgimgui_draw_buffer_link (ctx , buf )) {
40104033 _sgimgui_show_buffer (ctx , buf );
40114034 }
4012- _sgimgui_igtext (" Offset: %d" , bnd -> vertex_buffer_offsets [i ]);
4035+ _sgimgui_igsameline ();
4036+ _sgimgui_igtext ("offset: %d" , bnd -> vertex_buffer_offsets [i ]);
40134037 }
40144038 }
40154039 _sgimgui_igpopid ();
40164040 _sgimgui_igpushid ("bnd_ibuf" );
40174041 if (bnd -> index_buffer .id != SG_INVALID_ID ) {
40184042 sg_buffer buf = bnd -> index_buffer ;
40194043 if (buf .id != SG_INVALID_ID ) {
4020- _sgimgui_igseparator ();
4021- _sgimgui_igtext ("Index Buffer Slot:" );
4022- _sgimgui_igtext (" Buffer: " ); _sgimgui_igsameline ();
4044+ _sgimgui_igtext ("Index Buffer:" ); _sgimgui_igsameline ();
40234045 if (_sgimgui_draw_buffer_link (ctx , buf )) {
40244046 _sgimgui_show_buffer (ctx , buf );
40254047 }
4026- _sgimgui_igtext (" Offset: %d" , bnd -> index_buffer_offset );
4048+ _sgimgui_igsameline ();
4049+ _sgimgui_igtext ("offset: %d" , bnd -> index_buffer_offset );
40274050 }
40284051 }
40294052 _sgimgui_igpopid ();
40304053 _sgimgui_igpushid ("bnd_sbufs" );
40314054 for (int i = 0 ; i < SG_MAX_STORAGEBUFFER_BINDSLOTS ; i ++ ) {
40324055 sg_view view = bnd -> storage_buffers [i ];
40334056 if (view .id != SG_INVALID_ID ) {
4034- _sgimgui_igseparator ();
4035- _sgimgui_igtext ("Storage Buffer Slot #%d:" , i );
4036- _sgimgui_igtext (" View: " ); _sgimgui_igsameline ();
4057+ _sgimgui_igtext ("Storage Buffer #%d:" , i ); _sgimgui_igsameline ();
40374058 if (_sgimgui_draw_view_link (ctx , view )) {
40384059 _sgimgui_show_view (ctx , view );
40394060 }
@@ -4044,9 +4065,7 @@ _SOKOL_PRIVATE void _sgimgui_draw_bindings_panel(sgimgui_t* ctx, const sg_bindin
40444065 for (int i = 0 ; i < SG_MAX_TEXTURE_BINDSLOTS ; i ++ ) {
40454066 sg_view view = bnd -> textures [i ];
40464067 if (view .id != SG_INVALID_ID ) {
4047- _sgimgui_igseparator ();
4048- _sgimgui_igtext ("Texture Slot #%d:" , i );
4049- _sgimgui_igtext (" View: " ); _sgimgui_igsameline ();
4068+ _sgimgui_igtext ("Texture Slot %d:" , i ); _sgimgui_igsameline ();
40504069 if (_sgimgui_draw_view_link (ctx , view )) {
40514070 _sgimgui_show_view (ctx , view );
40524071 }
@@ -4057,9 +4076,7 @@ _SOKOL_PRIVATE void _sgimgui_draw_bindings_panel(sgimgui_t* ctx, const sg_bindin
40574076 for (int i = 0 ; i < SG_MAX_STORAGEIMAGE_BINDSLOTS ; i ++ ) {
40584077 sg_view view = bnd -> storage_images [i ];
40594078 if (view .id != SG_INVALID_ID ) {
4060- _sgimgui_igseparator ();
4061- _sgimgui_igtext ("Storage Image Slot #%d:" , i );
4062- _sgimgui_igtext (" View: " ); _sgimgui_igsameline ();
4079+ _sgimgui_igtext ("Storage Image #%d:" , i ); _sgimgui_igsameline ();
40634080 if (_sgimgui_draw_view_link (ctx , view )) {
40644081 _sgimgui_show_view (ctx , view );
40654082 }
@@ -4070,9 +4087,7 @@ _SOKOL_PRIVATE void _sgimgui_draw_bindings_panel(sgimgui_t* ctx, const sg_bindin
40704087 for (int i = 0 ; i < SG_MAX_SAMPLER_BINDSLOTS ; i ++ ) {
40714088 sg_sampler smp = bnd -> samplers [i ];
40724089 if (smp .id != SG_INVALID_ID ) {
4073- _sgimgui_igseparator ();
4074- _sgimgui_igtext ("Sampler Slot #%d:" , i );
4075- _sgimgui_igtext (" Sampler: " ); _sgimgui_igsameline ();
4090+ _sgimgui_igtext ("Sampler Slot #%d:" , i ); _sgimgui_igsameline ();
40764091 if (_sgimgui_draw_sampler_link (ctx , smp )) {
40774092 _sgimgui_show_sampler (ctx , smp );
40784093 }
@@ -4181,7 +4196,7 @@ _SOKOL_PRIVATE void _sgimgui_draw_uniforms_panel(sgimgui_t* ctx, const sgimgui_a
41814196}
41824197
41834198_SOKOL_PRIVATE void _sgimgui_draw_passaction_panel (const sg_pass_action * action , int num_color_atts ) {
4184- _sgimgui_igtext ("Pass Action: " );
4199+ _sgimgui_igtext ("Pass Action:" );
41854200 for (int i = 0 ; i < num_color_atts ; i ++ ) {
41864201 const sg_color_attachment_action * c_att = & action -> colors [i ];
41874202 _sgimgui_igtext (" Color Attachment %d:" , i );
@@ -4228,13 +4243,37 @@ _SOKOL_PRIVATE void _sgimgui_draw_passaction_panel(const sg_pass_action* action,
42284243 }
42294244}
42304245
4231- _SOKOL_PRIVATE void _sgimgui_draw_attachments_panel (sgimgui_t * ctx , const sg_attachments * atts ) {
4232- (void )ctx ; (void )atts ;
4233- _sgimgui_igtext ("FIXME FIXME FIXME!" );
4246+ _SOKOL_PRIVATE void _sgimgui_draw_attachments_panel (sgimgui_t * ctx , const sg_attachments * atts , int num_color_atts ) {
4247+ _sgimgui_igtext ("Attachments:" );
4248+ for (int i = 0 ; i < num_color_atts ; i ++ ) {
4249+ if (atts -> colors [i ].id != SG_INVALID_ID ) {
4250+ sg_view view = atts -> colors [i ];
4251+ _sgimgui_igtext (" Color Attachment #%d:" , i ); _sgimgui_igsameline ();
4252+ if (_sgimgui_draw_view_link (ctx , view )) {
4253+ _sgimgui_show_view (ctx , view );
4254+ }
4255+ }
4256+ }
4257+ for (int i = 0 ; i < num_color_atts ; i ++ ) {
4258+ if (atts -> resolves [i ].id != SG_INVALID_ID ) {
4259+ sg_view view = atts -> resolves [i ];
4260+ _sgimgui_igtext (" Resolve Attachment #%d:" , i ); _sgimgui_igsameline ();
4261+ if (_sgimgui_draw_view_link (ctx , view )) {
4262+ _sgimgui_show_view (ctx , view );
4263+ }
4264+ }
4265+ }
4266+ if (atts -> depth_stencil .id != SG_INVALID_ID ) {
4267+ sg_view view = atts -> depth_stencil ;
4268+ _sgimgui_igtext (" Depth Stencil Attachment:" ); _sgimgui_igsameline ();
4269+ if (_sgimgui_draw_view_link (ctx , view )) {
4270+ _sgimgui_show_view (ctx , view );
4271+ }
4272+ }
42344273}
42354274
42364275_SOKOL_PRIVATE void _sgimgui_draw_swapchain_panel (sg_swapchain * swapchain ) {
4237- _sgimgui_igtext ("Swapchain" );
4276+ _sgimgui_igtext ("Swapchain: " );
42384277 _sgimgui_igtext (" Width: %d" , swapchain -> width );
42394278 _sgimgui_igtext (" Height: %d" , swapchain -> height );
42404279 _sgimgui_igtext (" Sample Count: %d" , swapchain -> sample_count );
@@ -4274,7 +4313,7 @@ _SOKOL_PRIVATE void _sgimgui_draw_swapchain_panel(sg_swapchain* swapchain) {
42744313}
42754314
42764315_SOKOL_PRIVATE void _sgimgui_draw_pass_panel (sgimgui_t * ctx , sg_pass * pass ) {
4277- bool is_compute_pass = false ;
4316+ bool is_compute_pass = pass -> compute ;
42784317 bool is_attachments_pass = false;
42794318 bool is_swapchain_pass = false;
42804319 int num_color_atts = 0 ;
@@ -4285,17 +4324,21 @@ _SOKOL_PRIVATE void _sgimgui_draw_pass_panel(sgimgui_t* ctx, sg_pass* pass) {
42854324 is_attachments_pass = true;
42864325 }
42874326 }
4288- if (num_color_atts == 0 ) {
4327+ if (pass -> attachments .depth_stencil .id != SG_INVALID_ID ) {
4328+ is_attachments_pass = true;
4329+ }
4330+ if (!is_attachments_pass ) {
42894331 num_color_atts = 1 ;
42904332 is_swapchain_pass = true;
42914333 }
42924334 }
4293- _sgimgui_igtext ("Compute: %s" , _sgimgui_bool_string (pass -> compute ));
4335+ _sgimgui_igtext ("Compute: %s" , _sgimgui_bool_string (is_compute_pass ));
4336+ _sgimgui_igseparator ();
42944337 if (!is_compute_pass ) {
42954338 _sgimgui_draw_passaction_panel (& pass -> action , num_color_atts );
42964339 _sgimgui_igseparator ();
42974340 if (is_attachments_pass ) {
4298- _sgimgui_draw_attachments_panel (ctx , & pass -> attachments );
4341+ _sgimgui_draw_attachments_panel (ctx , & pass -> attachments , num_color_atts );
42994342 } else if (is_swapchain_pass ) {
43004343 _sgimgui_draw_swapchain_panel (& pass -> swapchain );
43014344 }
0 commit comments