Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vkCreateShaderModule() returns VK_ERROR_OUT_OF_HOST_MEMORY due to bad shader magic #22

Open
anon0824 opened this issue Sep 30, 2020 · 1 comment

Comments

@anon0824
Copy link

anon0824 commented Sep 30, 2020

Describe the bug
A clear and concise description of what the bug is.
Frequency of occurance. Command line output. Stack trace.

The attached Vulkan application runs on a Raspberry Pi 4, although the Pi4 uses a completely different Vulkan driver.
I was hoping to run it on a 3B+ using rpi-vk-driver, however when vkCreateShaderModule() is called, rpi-vk-driver returns VK_ERROR_OUT_OF_HOST_MEMORY.
Further inspection reveals that VK_ERROR_OUT_OF_HOST_MEMORY is returned because the shader magic for the shader does not add up, as seen here: https://github.com/Yours3lf/rpi-vk-driver/blob/master/driver/shader.c#L25

These same SPIR-V shaders run fine on a Raspberry Pi 4 (v3dv) as well as on mesa's RADV and NVIDIA's proprietary drivers for GTX graphics cards, so I suspect there is a driver issue.
Is there anything that can be done about this?

To Reproduce
Steps to reproduce the behavior:

  1. Extract the attached zip file to some directory- the executable "micro0" and "data" should be in the same directory.
  2. In a terminal, cd to the directory containing "micro0" and "data", then run micro0: ./micro0
  3. The program will error and close due to vkCreateShaderModule() failing, and if you add a printf() statement to the if(magic != 0x14E45250) if statement block in the driver, you will find the driver is returning VK_ERROR_OUT_OF_HOST_MEMORY due to bad shader magic.

Expected behavior
At the very least, vkCreateShaderModule() should complete successfully, because I know these are good/valid SPIR-V shaders.
Given vkCreateShaderModule() completes successfully, the program should probably run fine then-
there could be other non-driver issues running this application on the 3B+ that I have not discovered yet, but probably not since it runs fine on the Pi4 and other Vulkan drivers.

Device information (please complete the following information):

  • Device info (eg. Raspberry Pi 3 Model A+)
  • OS information (cat /proc/version, lsb_release -a)
  • Kernel module information: lsmod
  • Driver version (git commit ID or release info)
    Tested on a Raspberry Pi 3B+ running Raspbian.
    Driver version: git-c95f714
$ cat /proc/version
Linux version 5.4.51-v7+ (dom@buildbot) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611)) #1333 SMP Mon Aug 10 16:45:19 BST 2020

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Raspbian
Description:	Raspbian GNU/Linux 10 (buster)
Release:	10
Codename:	buster

$ lsmod
Module                  Size  Used by
cmac                   16384  1
rfcomm                 45056  4
bnep                   20480  2
hci_uart               40960  1
btbcm                  16384  1 hci_uart
bluetooth             376832  29 hci_uart,bnep,btbcm,rfcomm
ecdh_generic           16384  2 bluetooth
ecc                    32768  1 ecdh_generic
8021q                  32768  0
garp                   16384  1 8021q
stp                    16384  1 garp
llc                    16384  2 garp,stp
evdev                  24576  3
vc4                   233472  3
cec                    49152  1 vc4
hid_apple              16384  0
brcmfmac              319488  0
drm_kms_helper        184320  3 vc4
brcmutil               16384  1 brcmfmac
drm                   446464  3 vc4,drm_kms_helper
sha256_generic         16384  0
libsha256              20480  1 sha256_generic
drm_panel_orientation_quirks    16384  1 drm
snd_soc_core          200704  1 vc4
snd_compress           20480  1 snd_soc_core
cfg80211              679936  1 brcmfmac
snd_pcm_dmaengine      16384  1 snd_soc_core
syscopyarea            16384  1 drm_kms_helper
sysfillrect            16384  1 drm_kms_helper
sysimgblt              16384  1 drm_kms_helper
fb_sys_fops            16384  1 drm_kms_helper
rfkill                 28672  6 bluetooth,cfg80211
raspberrypi_hwmon      16384  0
bcm2835_codec          36864  0
i2c_bcm2835            16384  0
bcm2835_isp            32768  0
bcm2835_v4l2           45056  0
v4l2_mem2mem           32768  1 bcm2835_codec
bcm2835_mmal_vchiq     28672  3 bcm2835_isp,bcm2835_codec,bcm2835_v4l2
videobuf2_dma_contig    20480  2 bcm2835_isp,bcm2835_codec
videobuf2_vmalloc      16384  1 bcm2835_v4l2
videobuf2_memops       16384  2 videobuf2_dma_contig,videobuf2_vmalloc
videobuf2_v4l2         28672  4 bcm2835_isp,bcm2835_codec,bcm2835_v4l2,v4l2_mem2mem
videobuf2_common       57344  5 bcm2835_isp,bcm2835_codec,bcm2835_v4l2,v4l2_mem2mem,videobuf2_v4l2
snd_bcm2835            24576  1
snd_pcm                94208  4 vc4,snd_pcm_dmaengine,snd_bcm2835,snd_soc_core
videodev              237568  6 bcm2835_isp,bcm2835_codec,videobuf2_common,bcm2835_v4l2,v4l2_mem2mem,videobuf2_v4l2
snd_timer              32768  1 snd_pcm
mc                     45056  6 bcm2835_isp,bcm2835_codec,videobuf2_common,videodev,v4l2_mem2mem,videobuf2_v4l2
snd                    69632  9 snd_compress,snd_timer,snd_bcm2835,snd_soc_core,snd_pcm
vc_sm_cma              32768  2 bcm2835_isp,bcm2835_mmal_vchiq
uio_pdrv_genirq        16384  0
uio                    20480  1 uio_pdrv_genirq
fixed                  16384  0
i2c_dev                16384  0
ip_tables              28672  0
x_tables               32768  1 ip_tables
ipv6                  450560  24
nf_defrag_ipv6         20480  1 ipv6

micro0.zip

@Yours3lf
Copy link
Owner

Yours3lf commented Oct 1, 2020

This driver does not support SPIR-V, you need to use assembly, please see the numerous examples :)
If you feel like that, feel free to add SPIR-V support, I'd gladly merge it.

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

No branches or pull requests

2 participants