openvr icon indicating copy to clipboard operation
openvr copied to clipboard

Compositor->GetVulkanInstanceExtensionsRequired causes EXC_BAD_ACCESS on MacOS Mojave

Open burito opened this issue 7 years ago • 1 comments

Just what it says on the tin.

I've written a minimalist test example demonstrating the feature.

testvr.c.txt

I haven't managed to get this program to execute its final printf() on OSX. Works just fine on windows (and I expect Linux, but haven't tested just yet).

burito avatar Nov 30 '18 16:11 burito

Contents of textvr.c.txt

/*
Make sure to first...
cp OpenVR/bin/osx32/libopenvr_api.dylib .

Then compile with
clang testvr.c -IOpenVR/headers -otestvr -L. -lopenvr_api -rpath .
*/

#include <stdio.h>
#include <openvr_capi.h>

struct VR_IVRSystem_FnTable * OVR = NULL;
struct VR_IVRCompositor_FnTable * OVRC;
struct VR_IVRRenderModels_FnTable * OVRM;

S_API intptr_t VR_InitInternal( EVRInitError *peError, EVRApplicationType eType );
S_API void VR_ShutdownInternal();
S_API bool VR_IsHmdPresent();
S_API intptr_t VR_GetGenericInterface( const char *pchInterfaceVersion, EVRInitError *peError );
S_API bool VR_IsRuntimeInstalled();
S_API const char * VR_GetVRInitErrorAsSymbol( EVRInitError error );
S_API const char * VR_GetVRInitErrorAsEnglishDescription( EVRInitError error );


int main(int argc, char* argv[])
{
	EVRInitError eError;

	printf("About to VR_IsHmdPresent\n");
	if( !VR_IsHmdPresent() )
	{
		printf("VR Headset is not present\n");
		return 1;
	}
	
	printf("About to VR_IsRuntimeInstalled\n");
	if( !VR_IsRuntimeInstalled() )
	{
		printf("VR Runtime is not installed\n");
		return 1;
	}

	printf("About to VR_InitInternal\n");
	VR_InitInternal(&eError, EVRApplicationType_VRApplication_Scene);
	if (eError != EVRInitError_VRInitError_None)
	{
		printf("VR_InitInternal: %s\n", VR_GetVRInitErrorAsSymbol(eError));
		return 2;
	}

	char fnTableName[128];

	int result1 = sprintf(fnTableName, "FnTable:%s", IVRSystem_Version);
	printf("About to %s\n", fnTableName);
	OVR = (struct VR_IVRSystem_FnTable *)VR_GetGenericInterface(fnTableName, &eError);
	if (eError != EVRInitError_VRInitError_None)
	{
		printf("VR_GetGenericInterface(\"%s\"): %s\n", IVRSystem_Version, VR_GetVRInitErrorAsSymbol(eError));
		return 2;
	}

	result1 = sprintf(fnTableName, "FnTable:%s", IVRCompositor_Version);
	printf("About to %s\n", fnTableName);
	OVRC = (struct VR_IVRCompositor_FnTable *)VR_GetGenericInterface(fnTableName, &eError);
	if (eError != EVRInitError_VRInitError_None)
	{
		printf("VR_GetGenericInterface(\"%s\"): %s\n", IVRCompositor_Version, VR_GetVRInitErrorAsSymbol(eError));
		return 2;
	}

	result1 = sprintf(fnTableName, "FnTable:%s", IVRRenderModels_Version);
	printf("About to %s\n", fnTableName);
	OVRM = (struct VR_IVRRenderModels_FnTable *)VR_GetGenericInterface(fnTableName, &eError );
	if (eError != EVRInitError_VRInitError_None)
	{
		printf("VR_GetGenericInterface(\"%s\"): %s\n", IVRRenderModels_Version, VR_GetVRInitErrorAsSymbol(eError));
		return 2;
	}
	printf("About to OVRC->GetVulkanInstanceExtensionsRequired\n");

	uint32_t buffer_size = OVRC->GetVulkanInstanceExtensionsRequired( NULL, 0 );

	printf("Everything worked fine.\n");
	return 0;
}

Pyrolistical avatar Mar 07 '24 17:03 Pyrolistical