Comments (15)
Hello @sunbearc22.
Take a look at this part of the README: https://github.com/realitix/vulkan#functions
1
The wrapper handles VkResult for you. If VkResult is not VK_SUCCESS, an exception is raised.
So in your example, If you want to be sure that the function is OK:
try:
instance = vkCreateInstance(
pCreateInfo = inst_Info,
pAllocator = None)#,
#pInstance = inst)
except VkError:
print('error')
2
Here the magic of this wrapper, functions will return what you wait for. Don't forget something, in Python, there is no pointer like in C. When you pass pInstance
to the function, in the base Vulkan API, it's a pointer which is filled by the driver. You can't do that in pure Python. With CFFI, you can, and the wrapper does that for you. You don't have to know CFFI to use this wrapper, that's my rule.
When you call vkCreateInstance
, you don't pass pInstance
, you receive it. If the Vulkan function returns several elements, you will get a list
. It's what I do in the exemple.py
file.
Is this answer enough for you or do you need more informations ?
from vulkan.
Don't forget that I am on IRC, we can speak faster by chatting
from vulkan.
Thanks. I understood Ans 1. My bad for forgetting you wrote that in Readme. I was just about to reply with the same answer. I think it will be helpful to include your answer 1 as an example to Readme too. Just a suggestion.
For Ans 2, is there another example you can give?
from vulkan.
Just tried IRC ##vulkan but you are offline. I am sunbearc22.
from vulkan.
How do i see the next level of error message under VkError
?
VK_ERROR_OUT_OF_{HOST, DEVICE}_MEMORY
VK_ERROR_{INITIALIZATION, MEMORY_MAP}_FAILED
VK_ERROR_DEVICE_LOST
VK_ERROR_{EXTENSION, FEATURE, LAYER}_NOT_PRESENT
VK_ERROR_INCOMPATIBLE_DRIVER
VK_ERROR_TOO_MANY_OBJECTS
VK_ERROR_FORMAT_NOT_SUPPORTED
VK_ERROR_SURFACE_LOST_KHR
VK_ERROR_OUT_OF_DATE_KHR
VK_ERROR_INCOMPATIBLE_DISPLAY_KHR
VK_ERROR_NATIVE_WINDOW_IN_USE_KHR
VK_ERROR_VALIDATION_FAILED_EXT
Is this correct?
try:
instance = vkCreateInstance(
pCreateInfo = inst_Info,
pAllocator = None)#,
#pInstance = inst)
except VkError:
print('error')
if VkError == VK_ERROR_INCOMPATIBLE_DRIVER:
print("cannot find a compatible Vulkan ICD")
from vulkan.
Sorry I was offline.
For answer 2, I can point you different example in the example.py
file:
Return an object:
https://github.com/realitix/vulkan/blob/master/example/example.py#L18
https://github.com/realitix/vulkan/blob/master/example/example.py#L45
https://github.com/realitix/vulkan/blob/master/example/example.py#L200
Return a list:
https://github.com/realitix/vulkan/blob/master/example/example.py#L26
https://github.com/realitix/vulkan/blob/master/example/example.py#L30
https://github.com/realitix/vulkan/blob/master/example/example.py#L137
Return nothing:
https://github.com/realitix/vulkan/blob/master/example/example.py#L684
You can easily know if a function will return a list or an object, for example, if you look at vkCreateInstance
documentation here, the last parameter is indicated as
pInstance
points a VkInstance
handle in which the resulting instance is returned.
It's clear it will return an object.
For vkEnumerateInstanceExtensionProperties
here:
pProperties is either NULL or a pointer to an array of VkExtensionProperties structures.
It's clear it will return a list
. Moreover, you don't have to bother with pPropertyCount
, the wrapper do it for you. It's why you only pass the first parameter pLayerName
(None
in example.py
)
Is it ok now or do you need more informations ?
from vulkan.
For the last question:
You must do:
try:
instance = vkCreateInstance(
pCreateInfo = inst_Info,
pAllocator = None)
except VkErrorIncompatibleDriver:
print("cannot find a compatible Vulkan ICD")
except VkError:
print('error')
from vulkan.
Thanks for the Ans 2 elaboration. Helpful.
Can you clarify if my Exception code is correct for my question on Ans 1? I submitted the code with not python error but not sure if it is correct.
from vulkan.
I have just answered above.
from vulkan.
Sorry. Screen did not refresh so did not see your answer. So what is the purpose of VkError & VkException given that their subsets may be called directly?
from vulkan.
It's a classic Python pattern.
The goal of the parent exception is to catch all others errors. I mean, errors that you don't care.
For example, you could want to react if there is an error (and you don't need to know the exact error)...
In well written Python script, you will always find this patter, a precise exception that extend a global exception.
It gives you much freedom.
from vulkan.
Got it.
from vulkan.
Can I close this issue ?
from vulkan.
yep. Thanks.
from vulkan.
You're welcome !
from vulkan.
Related Issues (20)
- unable to install HOT 2
- Some API Wrappers are built-to-fail HOT 2
- Example program freezes my PC when interacting with something HOT 3
- Need VK_RESULT HOT 1
- Vulkan 1.2.141.2 HOT 3
- Debug Utils Messenger error HOT 4
- SDL2 example is now broken(easy to fix) HOT 3
- Vulkan is Failing to Install on Windows 10 HOT 3
- Generating for latest version (1.2.162.1) HOT 4
- Errors out HOT 1
- example_sdl2.py crash in mainloop: BadDrawable HOT 2
- vkAcquireNextImageKHR results in VkSuboptimalKhr HOT 1
- VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME constant missing? HOT 3
- Getting the int handles to vulkan objects. HOT 1
- Fix "module 'collections' has no attribute 'Iterable'" HOT 2
- Update version available on PyPi HOT 4
- Missing Struct VkPipelineCacheHeaderVersionOne HOT 1
- Cannot run example shown in readme HOT 2
- Compatibility flag is not available HOT 1
- vkGetPhysicalDeviceProperties2KHR / vkGetPhysicalDeviceProperties2 can not be used
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vulkan.