Vulkan Image View Feature Flags - vulkan

I get this validation message
If a VkSampler created with magFilter or minFilter equal to VK_FILTER_LINEAR and compareEnable equal to VK_FALSE is used to sample a VkImageView as a result of this command, then the image view's format features must contain VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT
But I can't see how to set the image view format features. Any ideas?

The message is telling you that you're using a linear sampler (magFilter or minFilter is VK_FILTER_LINEAR) to sample from an image view whose format doesn't have the VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT feature.
There are two ways to fix this:
Use a different sampler. If you don't need linear filtering, you can use a point sampler instead.
Use a different image view format. If you need linear filtering, you can use a format that supports it.

Related

Checking to see if an image format supports a usage in Vulkan?

If I want to see what an image format can be used for I can do the vkGetPhysicalDeviceImageFormatProperties2() and set the usage flag for the image format. I've noticed if the format isn't supported for those usages and settings the structure I pass in is set to all zero, and I can know if the format supports those uses. So if I want to know if VK_FORMAT_R8G8B8_UINT supports sampling from a shader I set the VK_IMAGE_USAGE_SAMPLED_BIT in the usage flags and call that function.
What I wanted to know is if that's equivalent to calling another function, called vkGetPhysicalDeviceFormatProperties2(), exactly the same name but without 'image' in the name, give that function the format, and check whether the VK_IMAGE_USAGE_SAMPLED_BIT is set.
So using the first method I give the format and usages I want from it, and then check if the values returned are zero max width, max height, etc, meaning those usages aren't supported, versus the second method of passing the format, getting back the flags and then checking the flags.
Are these two methods equivalent?
TL;DR: Do your image format checking properly: ask how you can use the format, then ask what functionality is available from usable format&usage combinations.
If you call vkGetPhysicalDeviceImageFormatProperties2 with usage flags and the like that don't correspond to a supported image type, you get an error: VK_ERROR_FORMAT_NOT_SUPPORTED. It inherits this due to the fact that it is said to "behave similarly to vkGetPhysicalDeviceImageFormatProperties", which has an explicit statement about this error:
If format is not a supported image format, or if the combination of format, type, tiling, usage, and flags is not supported for images, then vkGetPhysicalDeviceImageFormatProperties returns VK_ERROR_FORMAT_NOT_SUPPORTED.
Now normally, a function which gives rise to an error will yield undefined values in any return values. But there is a weird exception:
If the combination of parameters to vkGetPhysicalDeviceImageFormatProperties2 is not supported by the implementation for use in vkCreateImage, then all members of imageFormatProperties will be filled with zero.
However, there's an explicit note saying that this was old, bad behavior and is only preserved for compatibility's sake. Being a compatibility feature means that you can rely on it, but you shouldn't. Also, it only applies to the imageFormatProperties data and not any of the extension structures you can pass.
So it's best to just ignore this and ask your questions in the right order.

Valid displayAt() range in GMS

Images can be displayed at a specific location with the DisplayAt() command.
Does anyone know the valid range?
For example, DisplayAt(-9000, -9000) is that valid? What is the total valid range?
Of course in the example the image would not be seen within the GMS frame, but that is exactly what I need.
Thanks
Yes, negative values are completely ok and will indeed "place" the image outside the visible range of the window.
There is nothing like a "valid" range - the coordindates are just numbers. ( There is likely a limit when the value exceeds the value-range of the internallly used variable type to store the coordinates, possiblye long (4 byte signed integer). )
Just be aware that concepts like "front most" window will also apply if an image is outside the "visible" range. Images will f.e. also show up in the ImageBrowser regardless of their position on the workspace. The same is true for iterating through images on a workspace using f.e. CountImageDocuments() and GetImageDocument()
Some commands ( I think ShowImage() ) might have addtional code to ensure that images stay "visible" and might therefore shift the image back into the workspace range. Also using "auto-arrange" will take images from the "off" and place them back into the visible range.
So if you deliberatly use "off-screen" display, this is ok, but it might create some unintended side-effects. What is the exact purpose of using it this way? There might be more suitable concepts. (f.e. one can create imageDocuments and add ImageDisplays to them without the need of showing the imageDocument.) Image may also be temporarilly "hidden". Finally, one might condiser shiftung "unwanted" images onto a separate workspace.

Is there a maximum number of transformations, or maximum URL length, when using Cloudinary's URL API?

I try to build my opengraph images with Cloudinary, with a few transformations to add text.
This is what I tried to do:
https://res.cloudinary.com/nho/image/fetch/e_blur:2000,c_crop,ar_1200:630,b_white/e_grayscale/w_1200/l_fetch:aHR0cHM6Ly9uaWNvbGFzLWhvaXpleS5jb20vMjAxNy8xMC9jaHJvbWUtZW1vamktMTI4cHgtbWF4LnBuZw==,h_1.0,w_1.0,fl_relative,c_limit/b_rgb:3d2e68,o_40/w_1120,c_fit,l_text:georgia_80:Chrome%20fails%20showing%20big%20emojis,g_north_west,x_42,y_43,co_black,o_50/w_1120,c_fit,l_text:georgia_80:Chrome%20fails%20showing%20big%20emojis,g_north_west,x_41,y_42,co_black,o_75/w_1120,c_fit,l_text:georgia_80:Chrome%20fails%20showing%20big%20emojis,g_north_west,x_40,y_40,co_white/l_fetch:aHR0cHM6Ly9uaWNvbGFzLWhvaXpleS5jb20vYXNzZXRzL3Bob3RvLWRlLW5pY29sYXMtaG9pemV5LmpwZw==,g_south_west,x_40,y_40,c_fill,w_60,r_max/l_text:georgia_50:nicolas-hoizey.com,g_south_west,x_112,y_40,co_black/l_text:georgia_50:nicolas-hoizey.com,g_south_west,x_111,y_41,co_white/l_fetch:aHR0cHM6Ly9uaWNvbGFzLWhvaXpleS5jb20vYXNzZXRzL2xvZ29zL3R3aXR0ZXIucG5n,g_south_east,x_220,y_40,c_fill,w_50,r_max/l_text:georgia_50:nhoizey,g_south_east,x_40,y_40,co_black/l_text:georgia_50:nhoizey,g_south_east,x_41,y_41,co_white/https://nicolas-hoizey.com/2017/10/chrome-emoji-128px-max.png
I know the syntax is good, but I get a 400 Bad Request error.
If I remove the last transformation (/l_text:georgia_50:nhoizey,g_south_east,x_41,y_41,co_white) that adds text, it works:
https://res.cloudinary.com/nho/image/fetch/e_blur:2000,c_crop,ar_1200:630,b_white/e_grayscale/w_1200/l_fetch:aHR0cHM6Ly9uaWNvbGFzLWhvaXpleS5jb20vMjAxNy8xMC9jaHJvbWUtZW1vamktMTI4cHgtbWF4LnBuZw==,h_1.0,w_1.0,fl_relative,c_limit/b_rgb:3d2e68,o_40/w_1120,c_fit,l_text:georgia_80:Chrome%20fails%20showing%20big%20emojis,g_north_west,x_42,y_43,co_black,o_50/w_1120,c_fit,l_text:georgia_80:Chrome%20fails%20showing%20big%20emojis,g_north_west,x_41,y_42,co_black,o_75/w_1120,c_fit,l_text:georgia_80:Chrome%20fails%20showing%20big%20emojis,g_north_west,x_40,y_40,co_white/l_fetch:aHR0cHM6Ly9uaWNvbGFzLWhvaXpleS5jb20vYXNzZXRzL3Bob3RvLWRlLW5pY29sYXMtaG9pemV5LmpwZw==,g_south_west,x_40,y_40,c_fill,w_60,r_max/l_text:georgia_50:nicolas-hoizey.com,g_south_west,x_112,y_40,co_black/l_text:georgia_50:nicolas-hoizey.com,g_south_west,x_111,y_41,co_white/l_fetch:aHR0cHM6Ly9uaWNvbGFzLWhvaXpleS5jb20vYXNzZXRzL2xvZ29zL3R3aXR0ZXIucG5n,g_south_east,x_220,y_40,c_fill,w_50,r_max/l_text:georgia_50:nhoizey,g_south_east,x_40,y_40,co_black/https://nicolas-hoizey.com/2017/10/chrome-emoji-128px-max.png
Does it mean I stacked too much transformations in one single URL?
UPDATE:
I later tried to reduce the length of the first text (added 3 times to create a shadow), from Chrome%20fails%20showing%20big%20emojis to Chrome%20fails, and it worked too:
https://res.cloudinary.com/nho/image/fetch/e_blur:2000,c_crop,ar_1200:630,b_white/e_grayscale/w_1200/l_fetch:aHR0cHM6Ly9uaWNvbGFzLWhvaXpleS5jb20vMjAxNy8xMC9jaHJvbWUtZW1vamktMTI4cHgtbWF4LnBuZw==,h_1.0,w_1.0,fl_relative,c_limit/b_rgb:3d2e68,o_40/w_1120,c_fit,l_text:georgia_80:Chrome%20fails,g_north_west,x_42,y_43,co_black,o_50/w_1120,c_fit,l_text:georgia_80:Chrome%20fails,g_north_west,x_41,y_42,co_black,o_75/w_1120,c_fit,l_text:georgia_80:Chrome%20fails,g_north_west,x_40,y_40,co_white/l_fetch:aHR0cHM6Ly9uaWNvbGFzLWhvaXpleS5jb20vYXNzZXRzL3Bob3RvLWRlLW5pY29sYXMtaG9pemV5LmpwZw==,g_south_west,x_40,y_40,c_fill,w_60,r_max/l_text:georgia_50:nicolas-hoizey.com,g_south_west,x_112,y_40,co_black/l_text:georgia_50:nicolas-hoizey.com,g_south_west,x_111,y_41,co_white/l_fetch:aHR0cHM6Ly9uaWNvbGFzLWhvaXpleS5jb20vYXNzZXRzL2xvZ29zL3R3aXR0ZXIucG5n,g_south_east,x_220,y_40,c_fill,w_50,r_max/l_text:georgia_50:nhoizey,g_south_east,x_40,y_40,co_black/l_text:georgia_50:nhoizey,g_south_east,x_41,y_41,co_white/https://nicolas-hoizey.com/2017/10/chrome-emoji-128px-max.png
So I suspect the URL length might be the issue.
The issue is not the number of transformations per URL. The issue is that the transformation itself is too long. Please consider using named transformations to shorten it up.

how to get font size using pdfbox

Does anyone know if the method getFontSize in TextPosition always returns one and should I only use getFontSizeInPt to get the size of the font?
The problem I have is that getFontSizeInPt sometimes returns different values for the same sized text (I got 12 and 11 return for text in the same paragraph with the same size.
Does anyone know if the method getFontSize in TextPosition always returns one
It does not always return one.
Please be aware that in the PDF page content descriptions there are several settings which all influence the final text size:
the font size parameter of the font selecting operator Tf:
the text matrix set by the operator Tm;
the current transformation matrix set by the operator cm;
the UserUnit setting of the PDF page.
The final text size is the first value scaled by the text matrix, scaled again by the transformation matrix, and scaled once more by the user unit value.
(Actually there even are some more factors. E.g. if one uses rendering mode 2, fill & stroke, for a faux bold effect, this slightly increases the size, too.)
TextPosition.getFontSize returns the first value only.
TextPosition.getFontSizeInPt returns something like the first value scaled by the matrices. (something like because at first glance there seems to be another influence in it.)
Different PDF creators use these influences in different ways:
Some PDF creators use only the first value to set the font size and use the matrices only for operations not changing the effective font size, e.g. rotations.
Some PDF creators set the first value to 1 and scale using the matrices.
Some PDF creators fall inbetween and use both the first value and the scaling operations.
Thus, your PDFs seem to be created by software using the second way.
getFontSizeInPt sometimes returns different values for the same sized text (I got 12 and 11 return for text in the same paragraph with the same size.
Could you share a sample PDF with that issue? As mentioned above, at first glance there seem to be additional influences which might be incorrect. But there also might be something special about your PDF.

Is it possible to replace an axis with a parasiteaxis?

I have code that requires a ParasiteAxis instance, or at least something with a toggle_axisline method, in order to function properly. I'd like to be able to pass it any arbitrary axis created in any way (e.g., through a simple plot call).
How can I convert any given axis instance into a ParasiteAxis or HostAxis instance?
(for a specific use-case, see issue https://github.com/aplpy/aplpy/pull/88 and specifically the workaround implemented in commit https://github.com/keflavich/aplpy/commit/02ecd5386f7d3a93ca8e60c3db2b34ff3216060a)