Skip to content

Minor refactor for vulkan renderer#176

Open
xiaowei-guan wants to merge 12 commits into
flutter-tizen:masterfrom
xiaowei-guan:vulkan_refactor
Open

Minor refactor for vulkan renderer#176
xiaowei-guan wants to merge 12 commits into
flutter-tizen:masterfrom
xiaowei-guan:vulkan_refactor

Conversation

@xiaowei-guan

@xiaowei-guan xiaowei-guan commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Main changes:

  1. Move FindMemoryType method to vulkan renderer.
  2. Make GetDevice method to const.
  3. Cast to VkDeviceSize before multiplication.
  4. Add missing return value check for tbm_surface_get_info
  5. Initialize memory_type_index to 0 instead of -1
  6. Fix Vulkan texture error handling issues
  7. Change FindMemoryType output parameter from reference to pointer
  8. Add null check in FindMemoryType to prevent null pointer dereference
  9. Fix file descriptor leak in ExternalTextureSurfaceVulkanBufferDma
  10. Add pixel buffer dimension validation in ExternalTexturePixelVulkan

@xiaowei-guan xiaowei-guan marked this pull request as draft June 9, 2026 06:14

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors Vulkan memory type retrieval by moving FindMemoryType from individual texture classes to TizenRendererVulkan, adds a null check for pixel_buffer->buffer, and introduces error handling for vkMapMemory. Review feedback suggests refactoring CopyBufferToImage to propagate mapping failures and checking for null command buffers to prevent crashes. Additionally, it is recommended to ensure subclasses of ExternalTextureSurfaceVulkanBuffer can still access FindMemoryType, and to use pointers instead of references for output parameters in FindMemoryType to align with the Google C++ Style Guide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread flutter/shell/platform/tizen/external_texture_pixel_vulkan.cc
Comment thread flutter/shell/platform/tizen/tizen_renderer_vulkan.h Outdated
Comment thread flutter/shell/platform/tizen/tizen_renderer_vulkan.cc
Comment thread flutter/shell/platform/tizen/external_texture_pixel_vulkan.cc Outdated
- Check return value of tbm_surface_get_info() in CreateImage()
- Return false early if the call fails to prevent undefined behavior
- Follows the same error handling pattern as external_texture_surface_egl.cc

Co-Authored-By: Cline SR
Change uint32_t initialization from -1 to 0 to avoid implicit
signed-to-unsigned conversion, improving code clarity.

Co-Authored-By: Cline SR
- Change CopyBufferToImage return type from void to bool
- Add error propagation for vkMapMemory failure
- Add null check for BeginSingleTimeCommands return value
- Update caller in PopulateVulkanTexture to check return value

Fixes two critical issues identified by code review bot:
1. Lack of error propagation when vkMapMemory fails
2. Unchecked command buffer that could be VK_NULL_HANDLE

Co-Authored-By: Cline SR
…inter

Follow Google C++ Style Guide: output parameters should be passed as pointers
rather than references to make it clear at the call site that the argument
may be modified.

Changed:
- tizen_renderer_vulkan.h: Declaration updated to use uint32_t* instead of uint32_t&
- tizen_renderer_vulkan.cc: Implementation updated with pointer dereference
- external_texture_pixel_vulkan.cc: Call site updated to pass address

Co-Authored-By: Cline SR
@xiaowei-guan xiaowei-guan marked this pull request as ready for review June 18, 2026 02:28

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors Vulkan external texture handling by centralizing memory type lookup in TizenRendererVulkan, improving error handling, and adding resource cleanup on allocation failures. The review feedback recommends closing the exported file descriptor bo_fd if GetFdMemoryTypeIndex fails to prevent a leak, validating that pixel_buffer dimensions are positive before memory allocation, and adding a null check for the index_out pointer in FindMemoryType to avoid potential null pointer dereferences.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread flutter/shell/platform/tizen/external_texture_pixel_vulkan.cc
Comment thread flutter/shell/platform/tizen/tizen_renderer_vulkan.cc
…ence

- Add null pointer check for index_out parameter at the beginning of FindMemoryType function
- Return false early if index_out is null to prevent potential crashes

Co-Authored-By: Cline SR
Add close(bo_fd) call when GetFdMemoryTypeIndex() fails to prevent
file descriptor leak in AllocateAndBindMemory().

Co-Authored-By: Cline SR
- Validate width and height are non-zero before creating Vulkan image/buffer
- Prevents invalid memory allocation and Vulkan errors from zero-dimension textures

Co-Authored-By: Cline SR
Comment on lines 144 to 145
FT_LOG(Error) << "Fail to bind image memory";
return false;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In this case, is it unnecessary to call close(bo_fd);? It seems like it is missing.

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.

2 participants