问题描述
我正在尝试使用 uimage2D 在 glsl 中使用图像。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="From Riya" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/party_pic" />
</LinearLayout>
layout (binding = 0,rgba32ui)uniform writeonly uimage2D image;
void main(){
imageSize(image);
}
错误是因为 validation layer: Validation Error: [ UNASSIGNED-CoreValidation-DrawState-InvalidImageLayout ] Object 0: handle = 0x30a8448,type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x4dae5635 | Submitted command buffer expects VkImage 0x7c45730000000006[] (subresource: aspectMask 0x1 array layer 0,mip level 0) to be in layout VK_IMAGE_LAYOUT_GENERAL--instead,current layout is VK_IMAGE_LAYOUT_UNDEFINED.
。
我已将 ImageLayout 声明为 imageSize(image)
,但仍然收到此错误。
VK_IMAGE_LAYOUT_GENERAL
什么可能导致此错误?
解决方法
VkDescriptorImageInfo
不“声明”任何东西。它只是通知驱动程序您将使用哪种布局。错误就是这样说;你对司机撒了谎。你告诉它你会在 VK_IMAGE_LAYOUT_GENERAL
布局中给它图像,但是当它实际被采样时它实际上发现它在不同的布局中。
您需要通过管道障碍更改图像布局。