devmiyax / yabause

Yabause is a Sega Saturn emulator and took over as Yaba Sanshiro
http://www.uoyabause.org
GNU General Public License v2.0
214 stars 39 forks source link

Fail: createComputePipelines with eErrorUnkown #998

Open devmiyax opened 8 months ago

devmiyax commented 8 months ago

Envitonment: Redmagic 9 Pro Yabasanshiro 1.14.5

    frame #4: 0x0000007b33511dd0 libyabause_native.so`__cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 36
    frame #5: 0x0000007b33511d44 libyabause_native.so`__cxa_throw + 132
    frame #6: 0x0000007b32f36168 libyabause_native.so`RBGGeneratorVulkan::init(VIDVulkan*, int, int) [inlined] vk::detail::throwResultException(result=eErrorUnknown, message="vk::Device::createComputePipelines") at vulkan.hpp:6574:37
    frame #7: 0x0000007b32f35920 libyabause_native.so`RBGGeneratorVulkan::init(VIDVulkan*, int, int) [inlined] vk::resultCheck(result=eErrorUnknown, message="vk::Device::createComputePipelines", successCodes=([0] = eSuccess, [1] = ePipelineCompileRequired)) at vulkan.hpp:6776:7
    frame #8: 0x0000007b32f358c4 libyabause_native.so`RBGGeneratorVulkan::init(VIDVulkan*, int, int) [inlined] vk::ResultValue<std::__ndk1::vector<vk::Pipeline, std::__ndk1::allocator<vk::Pipeline>>> vk::Device::createComputePipelines<std::__ndk1::allocator<vk::Pipeline>, vk::DispatchLoaderStatic>(this=0x0000007b674cf378, pipelineCache=(m_pipelineCache = 0x0000000000000000), createInfos=0x0000007b674cef68, allocator=Optional<const vk::AllocationCallbacks> @ 0x0000007b674cf458, d=0x0000007b335f32d0) const at vulkan_funcs.hpp:3240:5
    frame #9: 0x0000007b32f357b0 libyabause_native.so`RBGGeneratorVulkan::init(this=0xb400007e6495f440, vulkan=0xb400007ca48dadb0, width=1104, height=2369) at ygl_texture.cpp:2832:14
    frame #10: 0x0000007b33006874 libyabause_native.so`VIDVulkan::init(this=0xb400007ca48dadb0) at VIDVulkan.cpp:260:17
    frame #11: 0x0000007b32ffff3c libyabause_native.so`::VIDVulkanInit() at VIDVulkan.cpp:80:60
    frame #12: 0x0000007b32e72af0 libyabause_native.so`VideoChangeCore(coreid=4) at vdp1.cpp:313:8
    frame #13: 0x0000007b32e729f8 libyabause_native.so`VideoInit(coreid=4) at vdp1.cpp:283:11
    frame #14: 0x0000007b32ec8430 libyabause_native.so`YabauseInit(init=0x0000007b674cfa20) at yabause.c:282:8
    frame #15: 0x0000007b32dcbc60 libyabause_native.so`YabauseInit() at yui.cpp:1584:11
    frame #16: 0x0000007b32dcdad4 libyabause_native.so`renderLoop() at yui.cpp:2244:26
    frame #17: 0x0000007b32dcad78 libyabause_native.so`threadStartCallback(myself=0x0000000000000000) at yui.cpp:2457:5
    frame #18: 0x0000007f4f2f9bc4 libc.so`__pthread_start(void*) + 212
    frame #19: 0x0000007f4f2934e8 libc.so`__start_thread + 72
devmiyax commented 8 months ago

createComputePipelines returns eErrorUnknown.

OK

"      uint caddr = addr; \n"
"      kdata = vram[ caddr>>2 ]; \n"

eErrorUnknown

"      uint caddr = addr + 0x2u; \n"
"      kdata = vram[ caddr>>2 ]; \n"

it's crazy.

devmiyax commented 8 months ago

OK

"    /*if ((kdata&0x8000u)!=0x0u) { rtn = 1; }\n"
"      else*/ if((kdata&0x4000u)!=0u) ky=float( int(kdata&0x7FFFu)| int(0xFFFF8000u) )/1024.0; else ky=float(kdata&0x7FFFu)/1024.0;\n"

eErrorUnknown

"   if ((kdata&0x8000u)!=0x0u) { rtn = 1; }\n"
"      else if((kdata&0x4000u)!=0u) ky=float( int(kdata&0x7FFFu)| int(0xFFFF8000u) )/1024.0; else ky=float(kdata&0x7FFFu)/1024.0;\n"

it's caoss.

devmiyax commented 8 months ago

OK

"    if( (addr & 0x02u) != 0u ) { kdata >>= 16; } \n"
"    //kdata = (( (kdata >> 8) & 0xFFu) | ((kdata) & 0xFFu) << 8);\n"
"    ky = float(kdata);  \n"
"    if( (addr & 0x02u) != 0u ) { kdata >>= 16; } \n"
"    kdata = ((kdata >> 8) & 0xFFu) /*| ((kdata) & 0xFFu) << 8)*/;\n"
"    ky = float(kdata);  \n"

eErrorUnknown

"    if( (addr & 0x02u) != 0u ) { kdata >>= 16; } \n"
"    kdata = (( (kdata >> 8) & 0xFFu) | ((kdata) & 0xFFu) << 8);\n"
"    ky = float(kdata);  \n"

OK

"    if( (addr & 0x02u) != 0u ) { kdata >>= 16; } \n"
"    kdata = ((kdata >> 8) & 0xFFu) + ((kdata & 0xFFu) << 8);\n"
"    ky = float(kdata);  \n"
devmiyax commented 8 months ago

minimum code

OK

precision highp float;
precision highp int;
precision highp image2D;
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
layout(rgba8, binding = 0)  uniform writeonly image2D outSurface;
layout(std430, binding = 1) readonly buffer VDP2C { uint cram[]; };
void main() {
  ivec2 texel = ivec2(gl_GlobalInvocationID.xy);
  uint kdata = cram[texel.x];
  kdata = ((kdata >> 8) & 0xFFu) + ((kdata << 8) & 0xFF00u);
  if ((kdata&0x8000u)!=0x0u) { return; }
  imageStore(outSurface,texel,vec4(float(kdata)));
}

eErrorUnknown

precision highp float;
precision highp int;
precision highp image2D;
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
layout(rgba8, binding = 0)  uniform writeonly image2D outSurface;
layout(std430, binding = 1) readonly buffer VDP2C { uint cram[]; };
void main() {
  ivec2 texel = ivec2(gl_GlobalInvocationID.xy);
  uint kdata = cram[texel.x];
  kdata = ((kdata >> 8) & 0xFFu) | ((kdata << 8) & 0xFF00u);
  if ((kdata&0x8000u)!=0x0u) { return; }
  imageStore(outSurface,texel,vec4(float(kdata)));
}
devmiyax commented 7 months ago

OK

    "  kdata = ( ((kdata>>8)&0x00FFu) | (kdata<<8) ) & 0xFFFFu ;\n"

eErrorUnknown

    "  kdata = ((kdata >> 8) & 0xFFu) | ((kdata << 8) & 0xFF00u);\n"
devmiyax commented 7 months ago

bad.spv.txt good.spv.txt

devmiyax commented 7 months ago

image

ASISBusiness commented 7 months ago

Envitonment: Redmagic 9 Pro Yabasanshiro 1.14.5

    frame #4: 0x0000007b33511dd0 libyabause_native.so`__cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 36
    frame #5: 0x0000007b33511d44 libyabause_native.so`__cxa_throw + 132
    frame #6: 0x0000007b32f36168 libyabause_native.so`RBGGeneratorVulkan::init(VIDVulkan*, int, int) [inlined] vk::detail::throwResultException(result=eErrorUnknown, message="vk::Device::createComputePipelines") at vulkan.hpp:6574:37
    frame #7: 0x0000007b32f35920 libyabause_native.so`RBGGeneratorVulkan::init(VIDVulkan*, int, int) [inlined] vk::resultCheck(result=eErrorUnknown, message="vk::Device::createComputePipelines", successCodes=([0] = eSuccess, [1] = ePipelineCompileRequired)) at vulkan.hpp:6776:7
    frame #8: 0x0000007b32f358c4 libyabause_native.so`RBGGeneratorVulkan::init(VIDVulkan*, int, int) [inlined] vk::ResultValue<std::__ndk1::vector<vk::Pipeline, std::__ndk1::allocator<vk::Pipeline>>> vk::Device::createComputePipelines<std::__ndk1::allocator<vk::Pipeline>, vk::DispatchLoaderStatic>(this=0x0000007b674cf378, pipelineCache=(m_pipelineCache = 0x0000000000000000), createInfos=0x0000007b674cef68, allocator=Optional<const vk::AllocationCallbacks> @ 0x0000007b674cf458, d=0x0000007b335f32d0) const at vulkan_funcs.hpp:3240:5
    frame #9: 0x0000007b32f357b0 libyabause_native.so`RBGGeneratorVulkan::init(this=0xb400007e6495f440, vulkan=0xb400007ca48dadb0, width=1104, height=2369) at ygl_texture.cpp:2832:14
    frame #10: 0x0000007b33006874 libyabause_native.so`VIDVulkan::init(this=0xb400007ca48dadb0) at VIDVulkan.cpp:260:17
    frame #11: 0x0000007b32ffff3c libyabause_native.so`::VIDVulkanInit() at VIDVulkan.cpp:80:60
    frame #12: 0x0000007b32e72af0 libyabause_native.so`VideoChangeCore(coreid=4) at vdp1.cpp:313:8
    frame #13: 0x0000007b32e729f8 libyabause_native.so`VideoInit(coreid=4) at vdp1.cpp:283:11
    frame #14: 0x0000007b32ec8430 libyabause_native.so`YabauseInit(init=0x0000007b674cfa20) at yabause.c:282:8
    frame #15: 0x0000007b32dcbc60 libyabause_native.so`YabauseInit() at yui.cpp:1584:11
    frame #16: 0x0000007b32dcdad4 libyabause_native.so`renderLoop() at yui.cpp:2244:26
    frame #17: 0x0000007b32dcad78 libyabause_native.so`threadStartCallback(myself=0x0000000000000000) at yui.cpp:2457:5
    frame #18: 0x0000007f4f2f9bc4 libc.so`__pthread_start(void*) + 212
    frame #19: 0x0000007f4f2934e8 libc.so`__start_thread + 72
devmiyax commented 7 months ago

workaround is found!

" kdata = ((kdata>>8)&0xFFu) | ((kdata << 8) & 0xFFFFFF00u);\n"