Quantcast
Jump to content


New Vulkan Extensions for Mobile: Legacy Support Extensions


Recommended Posts

2021-06-21-01-banner.jpg

The Samsung Developers team works with many companies in the mobile and gaming ecosystems. We're excited to support our partner, Arm, as they bring timely and relevant content to developers looking to build games and high-performance experiences. This Vulkan Extensions series will help developers get the most out of the new and game-changing Vulkan extensions on Samsung mobile devices.

Android is enabling a host of useful new Vulkan extensions for mobile. These new extensions are set to improve the state of graphics APIs for modern applications, enabling new use cases and changing how developers can design graphics renderers going forward. I have already provided information about ‘maintenance extensions’. However, another important extension that I explore in this blog is ‘legacy support extensions’.

Vulkan is increasingly being used as a portable “HAL”. The power and flexibility of the API allows for great layered implementations. There is a lot of effort spent in the ecosystem enabling legacy graphics APIs to run efficiently on top of Vulkan. The bright future for driver developers is a world where GPU drivers only implement Vulkan, and where legacy APIs can be implemented on top of that driver.

To that end, there are several features which are generally considered backwards today. They should not be used in new applications unless absolutely required. These extensions exist to facilitate old applications which need to keep running through API translation layers such as ANGLE, DXVK, Zink, and so on.

VK_EXT_transform_feedback

Speaking the name of this extension causes the general angst level to rise in a room of driver developers. In the world of Direct3D, this feature is also known as stream-out.

The core feature of this extension is that whenever you render geometry, you can capture the resulting geometry data (position and vertex outputs) into a buffer. The key complication from an implementation point of view is that the result is ordered. This means there is no 1:1 relation for input vertex to output data since this extension is supposed to work with indexed rendering, as well as strip types (and even geometry shaders and tessellation, oh my!).

This feature was invented in a world before compute shaders were conceived. The only real method to perform buffer <-> buffer computation was to make use of transform feedback, vertex shaders and rasterizationDiscard. Over time, the functionality of Transform Feedback was extended in various ways, but today it is essentially obsoleted by compute shaders.

There are, however, two niches where this extension still makes sense - graphics debuggers and API translation layers. Transform Feedback is extremely difficult to emulate in the more complicated cases.

Setting up shaders

In vertex-like shader stages, you need to set up which vertex outputs to capture to a buffer. The shader itself controls the memory layout of the output data. This is unlike other APIs, where you use the graphics API to specify which outputs to capture based on the name of the variable.

Here is an example Vulkan GLSL shader:

#version 450

layout(xfb_stride = 32, xfb_offset = 0, xfb_buffer = 0, location = 0)
out vec4 vColor;
layout(xfb_stride = 32, xfb_offset = 16, xfb_buffer = 0, location = 1)
out vec4 vColor2;

layout(xfb_buffer = 1, xfb_stride = 16) out gl_PerVertex {
    layout(xfb_offset = 0) vec4 gl_Position;
};

void main()
{
	gl_Position = vec4(1.0);
	vColor = vec4(2.0);
	vColor2 = vec4(3.0);
}

The resulting SPIR-V will then look something like:

Capability TransformFeedback
ExecutionMode 4 Xfb
Decorate 8(gl_PerVertex) Block
Decorate 10 XfbBuffer 1
Decorate 10 XfbStride 16
Decorate 17(vColor) Location 0
Decorate 17(vColor) XfbBuffer 0
Decorate 17(vColor) XfbStride 32
Decorate 17(vColor) Offset 0
Decorate 20(vColor2) Location 1
Decorate 20(vColor2) XfbBuffer 0
Decorate 20(vColor2) XfbStride 32
Decorate 20(vColor2) Offset 16

Binding transform feedback buffers

Once we have a pipeline which can emit transform feedback data, we need to bind buffers:

vkCmdBindTransformFeedbackBuffersEXT(cmd,
firstBinding, bindingCount,
pBuffers, pOffsets, pSizes);

To enable a buffer to be captured, VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT is used.

Starting and stopping capture

Once we know where to write the vertex output data, we will begin and end captures. This needs to be done inside a render pass:

vkCmdBeginTransformFeedbackEXT(cmd,
	firstCounterBuffer, counterBufferCount,
	pCounterBuffers, pCounterBufferOffsets);

A counter buffer allows us to handle scenarios where we end a transform feedback and continue capturing later. We would not necessarily know how many bytes were written by the last transform feedback, so it is critical that we can let the GPU maintain a byte counter for us.

vkCmdDraw(cmd, …);
vkCmdDrawIndexed(cmd, …);

Then we can start rendering. Vertex outputs are captured to the buffers in-order.

vkCmdEndTransformFeedbackEXT(cmd,
	firstCounterBuffer, counterBufferCount,
	pCounterBuffers, pCounterBufferOffsets);

Once we are done capturing, we end the transform feedback and, with the counter buffers, we can write the new buffer offsets into the counter buffer.

Indirectly drawing transform feedback results

This feature is a precursor to the more flexible indirect draw feature we have in Vulkan, but there was a time when this feature was the only efficient way to render transform feedbacked outputs. The fundamental problem is that we do not necessarily know exactly how many primitives have been rendered. Therefore, to avoid stalling the CPU, it was required to be able to indirectly render the results with a special purpose API.

vkCmdDrawIndirectByteCountEXT(cmd,
	instanceCount, firstInstance,
	counterBuffer, counterBufferOffset,
	counterOffset, vertexStride);

This works similarly to a normal indirect draw call, but instead of providing a vertex count, we give it a byte count and let the GPU perform the divide instead. This is nice, as otherwise we would have to dispatch a tiny compute kernel that converts a byte count to an indirect draw.

Queries

The offset counter is sort of like a query, but if the transform feedback buffers overflow, any further writes are ignored. The VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT queries how many primitives were generated. It also lets you query how many primitives were attempted to be written. This makes it possible to detect overflow if that is desirable.

VK_EXT_line_rasterization

Line rasterization is a tricky subject and is not normally used for gaming applications since they do not scale with resolution and their exact behavior is not consistent across all GPU implementations.

In the world of CAD, however, this feature is critical, and older OpenGL APIs had extensive support for quite fancy line rendering methods. This extension essentially brings back those workstation features. Advanced line rendering can occasionally be useful for debug tooling and visualization as well.

The feature zoo

typedef struct VkPhysicalDeviceLineRasterizationFeaturesEXT {
	VkStructureType sType;
	void*          		pNext;
	VkBool32       rectangularLines;
	VkBool32       bresenhamLines;
	VkBool32       smoothLines;
	VkBool32       stippledRectangularLines;
	VkBool32       stippledBresenhamLines;
	VkBool32       stippledSmoothLines;
} VkPhysicalDeviceLineRasterizationFeaturesEXT;

This extension supports a lot of different feature bits. I will try to summarize what they mean below.

Rectangular lines vs parallelogram

When rendering normal lines in core Vulkan, there are two ways lines can be rendered. If VkPhysicalDeviceLimits::strictLines is true, a line is rendered as if the line is a true, oriented rectangle. This is essentially what you would get if you rendered a scaled and rotated rectangle yourself. The hardware just expands the line along the perpendicular axis of the line axis.

In non-strict rendering, we get a parallelogram. The line is extended either in X or Y directions.

(From Vulkan specification)

Bresenham lines

Bresenham lines reformulate the line rendering algorithm where each pixel has a diamond shaped area around the pixel and coverage is based around intersection and exiting the area. The advantage here is that rendering line strips avoids overdraw. Rectangle or parallelogram rendering does not guarantee this, which matters if you are rendering line strips with blending enabled.

(From Vulkan specification)

Smooth lines

Smooth lines work like rectangular lines, except the implementation can render a little further out to create a smooth edge. Exact behavior is also completely unspecified, and we find the only instance of the word “aesthetic” in the entire specification, which is amusing. This is a wonderfully vague word to see in the Vulkan specification, which is otherwise no-nonsense normative.

This feature is designed to work in combination with alpha blending since the smooth coverage of the line rendering is multiplied into the alpha channel of render target 0’s output.

Line stipple

A “classic” feature that will make most IHVs cringe a little. When rendering a line, it is possible to mask certain pixels in a pattern. A counter runs while rasterizing pixels in order and with line stipple you control a divider and mask which generates a fixed pattern for when to discard pixels. It is somewhat unclear if this feature is really needed when it is possible to use discard in the fragment shader, but alas, legacy features from the early 90s are sometimes used. There were no shaders back in those days.

Configuring rasterization pipeline state

When creating a graphics pipeline, you can pass in some more data in pNext of rasterization state:

typedef struct VkPipelineRasterizationLineStateCreateInfoEXT {
	VkStructureType    sType;
	const void*             pNext;
	VkLineRasterizationModeEXT lineRasterizationMode;
	VkBool32                stippledLineEnable;
	uint32_t                   lineStippleFactor;
	uint16_t                   lineStipplePattern;
} VkPipelineRasterizationLineStateCreateInfoEXT;

typedef enum VkLineRasterizationModeEXT {
    VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT = 0,
    VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT = 1,
    VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT = 2,
    VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT = 3,
} VkLineRasterizationModeEXT;

If line stipple is enabled, the line stipple factors can be baked into the pipeline, or be made a dynamic pipeline state using VK_DYNAMIC_STATE_LINE_STIPPLE_EXT.

In the case of dynamic line stipple, the line stipple factor and pattern can be modified dynamically with:

vkCmdSetLineStippleEXT(cmd, factor, pattern);

VK_EXT_index_type_uint8

In OpenGL and OpenGL ES, we have support for 8-bit index buffers. Core Vulkan and Direct3D however only support 16-bit and 32-bit index buffers. Since emulating index buffer formats is impractical with indirect draw calls being a thing, we need to be able to bind 8-bit index buffers. This extension does just that.

This is probably the simplest extension we have look at so far:

vkCmdBindIndexBuffer(cmd, indexBuffer, offset, VK_INDEX_TYPE_UINT8_EXT);
vkCmdDrawIndexed(cmd, …);

Conclusion

I have been through the 'maintenance' and 'legacy support' extensions that are part of the new Vulkan extensions for mobile. In the next three blogs, I will go through what I see as the 'game-changing' extensions from Vulkan - the three that will help to transform your games during the development process.

Follow Up

Thanks to Hans-Kristian Arntzen and the team at Arm for bringing this great content to the Samsung Developers community. We hope you find this information about Vulkan extensions useful for developing your upcoming mobile games. The original version of this article can be viewed at Arm Community.

The Samsung Developers site has many resources for developers looking to build for and integrate with Samsung devices and services. Stay in touch with the latest news by creating a free account or by subscribing to our monthly newsletter. Visit the Marketing Resources page for information on promoting and distributing your apps and games. Finally, our developer forum is an excellent way to stay up-to-date on all things related to the Galaxy ecosystem.

View the full blog at its source

Link to comment
Share on other sites



  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Similar Topics

    • By Samsung Newsroom
      Samsung Electronics today announced the installation of its Outdoor LED Signage XHB Series (P8) at the flagship location of Shinsegae Department Store in Seoul, South Korea. Unveiled during the “2024 Lights Up SEOUL, KOREA” event today, the installation is set to establish Myeongdong Square in Seoul as Korea’s new premier landmark, featuring a stunning media lighting display that illuminates the heart of Seoul’s iconic shopping district.
       
      “Our LED displays present unlimited possibilities for places like Myeongdong to bear new elements of cultural significance,” said Hoon Chung, Executive Vice President of the Visual Display Business at Samsung Electronics. “This installation gives us an opportunity to showcase in the biggest way possible that our outdoor digital displays are built to engage, built to deliver impactful content, and built to last.”
       
      Located within the Myeongdong Special Tourist Zone Area, Shinsegae Department Store is uniquely positioned as a free outdoor advertising zone that enables creative and expansive installations. Samsung’s massive outdoor LED signage featuring an anamorphic 8K display, wraps around the entire outer wall of the building, measuring 71.8 meters in width and 17.9 meters in height — equivalent in size to three basketball courts.
       

       
      Spanning a total area of 1,285 square meters, the display is designed for resilience in harsh weather, featuring an IP66 rating for dust and water resistance, and UL 48 and UL 746C certifications1 for year-round durability. The installation is engineered for high visibility and vibrant color accuracy, with support for HDR10+ technology to deliver sharp contrast and rich visuals. With a max brightness of 8,000 nits,2 the display ensures exceptional clarity even in direct sunlight. Its high refresh rate of 7,680Hz minimizes flicker and the moiré effect,3 ensuring a stable display that remains visually crisp, even through camera lenses.
       
      Samsung’s track record of success with digital signage spans prominent venues worldwide. In South Korea, Samsung provided the country’s largest ever high-definition LED signage to Coex SM Town, while transformative installations at New York’s Citi Field and Houston’s Minute Maid Park set new standards for in-stadium displays. At Citi Field, Samsung installed the largest scoreboard in professional baseball, featuring over 29,800 square feet of LED screens that immerse fans in the action from every angle. Similarly, at Minute Maid Park, Samsung’s high-definition LED technology redefined the fan experience with massive outdoor displays and a dynamic new main scoreboard, all designed to enhance the excitement of the game.
       

       
      In Myeongdong, the new installation will not only host engaging advertisements and dynamic video content, but also transform into a breathtaking annual Christmas media façade, creating a festive atmosphere for visitors.
       
      “Shinsegae’s media façade, beloved by global customers for the past 10 years, has now been recreated as Shinsegae Square. This transformation paves the way for it to become an iconic landmark of Seoul, making it not only a must-visit attraction but also a central hub for K-culture. We are excited to partner with Samsung to bring our customers unique experiences that blend heritage and digital technology,” Shinsegae spokesperson said.
       
      Samsung’s Outdoor LED Signage is renowned for exceptional performance in demanding environments, evidenced by award-winning deployments at iconic venues such as Inglewood, California’s SoFi Stadium, which boasts the world’s largest LED videoboard ever built for sports, and the Formula 1 Las Vegas Grand Prix, where Samsung installed a 481-foot-long rooftop LED display in the shape of the F1 logo. As Myeongdong evolves into a global tourism destination, Samsung continues to lead with solutions that inspire and engage.
       
       
       
      1 UL 48 and UL 746C certifications, issued by Underwriters Laboratories (UL), verify compliance with safety standards for electric signs and durability of materials in outdoor environments, including UV and weather resistance.
      2 Maximum brightness measured post-calibration; actual values may vary with conditions.
      3 The moiré effect is an undesirable visual phenomenon that occurs when repetitive patterns, such as lines, are captured in photographs.
      View the full article
    • By Samsung Newsroom
      Samsung Electronics today announced that its proprietary cryptography module, Samsung CryptoCore,1 has earned the prestigious FIPS 140-3 certification2 from the National Institute of Standards and Technology (NIST). This certification underscores Samsung’s commitment to providing industry-leading security and data protection for Smart TV users.
       
      “As home entertainment systems become more connected, it becomes critical for technology companies to safeguard the personal data that enables the seamless connectivity enjoyed by so many,” said Yongjae Kim, Executive Vice President and Head of the R&D Team, Visual Display Business at Samsung Electronics. “By integrating the FIPS 140-3-certified CryptoCore into our Smart TVs, Samsung is taking our commitment to secure home entertainment a step further and ensuring that our users can freely experience the value of our products.”
       
      Beginning in 2025, Samsung CryptoCore will be fully integrated into Tizen OS,3 Samsung’s Smart TV operating system, enhancing the security of key products such as TVs, monitors and digital signage. With Samsung CryptoCore embedded in Tizen OS, personal data linked to Samsung accounts will be securely encrypted, SmartThings authentication information will be protected from external hacking threats and content viewed on TVs will benefit from enhanced copyright protection.
       
      Since 2015, Samsung has equipped its Smart TVs with Samsung Knox,4 a security platform that has earned Common Criteria (CC) certification5 for 10 consecutive years. But with its newly acquired FIPS 140-3 certification, Samsung has strengthened its defenses against hacking and data breaches even further, proactively protecting personal information with advanced encryption technology.
       
      Recognized by governments in 10 countries,6 the FIPS 140-3 certification requires comprehensive testing of cryptographic modules to ensure their security, integrity and reliability. For users, this means Samsung Smart TVs offer cutting-edge protection against privacy breaches, allowing them to enjoy their content, connect smart devices and engage with IoT services securely and without concerns.
       


       
      1 Samsung CryptoCore is a software library that encrypts and decrypts data during both transmission and storage.
      2 Federal Information Processing Standard (FIPS) 140-3 covers the security requirements for cryptographic modules.
      3 Tizen OS 9.0.
      4 Samsung Knox provides privacy protection on its Smart TVs through features like Tizen OS Monitoring, Phishing Site Blocking and Knox Vault. Knox Vault is available only on the QN900D and QN800D models.
      5 Common Criteria (CC) certification is a global security standard recognized by 31 countries for IT product integrity.
      6 Recognized in the United States, Canada, UK, Germany, France, South Korea, Japan, Singapore, Australia and New Zealand.
      View the full article
    • By Samsung Newsroom
      Start Date Nov 21, 2024 - Nov 21, 2024
      Location Online
      Samsung Developer Conference Korea 2024 (SDC24 Korea) will be held online on November 21st.
      Since its inception in 2014, SDC24 Korea has been emphasizing the importance of software by expanding from open source to all areas of software development. It's now celebrating its 11th anniversary.
      This year's SDC24 Korea features a variety of exciting events including keynote speeches from our CTO and other renowned speakers as well as more than 29 technical sessions.
      Furthermore, we are excited to share that SDC24 Korea will incorporate content from the recent SDC24 conference held in the US on October 3rd (US time), providing attendees with even more opportunities to learn, connect, and engage.
      Anyone can attend SDC24 Korea through pre-registration, and keynotes and major sessions will be announced on the SDC24 Korea website. For more information, please visit the SDC24 Korea website!

      Visit SDC24 Website View the full blog at its source
    • By Alex
      Samsung goes big on smart fridges with 10 new models
      With Family Hub 2.0, you can do more on the fridges' 21.5-inch Tizen-powered screens.

      Samsung must have done alright with its crazy WiFi-connected smart fridges last year, because it's launching six more in 2017, for a total of 10. That includes both three-door, four-door and four-door "flex" models with dual freezers (shown above). It's also updated the fridge's OS to Family Hub 2.0 with a new interface that lets everyone have a profile, complete with avatar. From there, you can share photos, calendars and handwritten memos on your fridge's giant 21.5-inch LED touchscreen. Voice control and entertainment apps like Pandora are on offer as well.
      As before, the Tizen-powered fridges can take a picture of their contents each time you open the door, and let you replenish stocks using "Groceries by MasterCard." Taking a page from Amazon's Alexa, they can also read out recipes via the AllRecipes-powered app, and run apps like Spotify, GrubHub and Glympse. Using voice control, you can run apps, get the weather and update grocery lists, for instance.
      Samsung didn't say exactly which models are coming, how much they cost or even what regular refrigerator-type features they have. However, last year's Family Hub 1.0 model, when it finally came out in May, cost $6,000, so we assume it can do pretty much everything you'd want. Hopefully with 10 models in total, some will be more affordable -- naturally, we'll try to get a look during the show and ask Samsung for ourselves.
      Click here to catch up on the latest news from CES 2017. Source: https://www.engadget.com/2017/01/03/samsung-goes-big-on-smart-fridges-with-ten-new-models/ In this article: AllRecipes, ces2017, familyhub, FamilyHub2.0, food and drink, food-and-drink,foodanddrink, gear, home, HomeDelivery, MasterCard, pandora, refrigerator, samsung,SmartFridge, voicecontrol
    • By Mahesh Gadhe
      Hi 
      I have a Samsung professional digital signage display device (TV) where I manually download and install the app through the web app address. Instead, I want the app to auto-update. If I replace the previously installed file with a new one, the device should automatically detect the new version, download, and install it without any manual interaction.





×
×
  • Create New...