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 Art Store is today welcoming the arrival of 12 of Jean-Michel Basquiat’s most striking works, in partnership with Artestar and The Estate of Jean-Michel Basquiat. This is the first time the iconic artist’s work has been officially released for digital display, and joins works from leading museums, collections and artists around the world available from Samsung Art Store.
       
      ▲ Pez Dispenser (1984), one of Basquiat’s most recognizable artworks, displayed on The Frame
       
      Samsung Art Store is a subscription service that enables owners of The Frame to continuously transform any space with over 2,500 pieces of digital art, including works from the most renowned artists, museums and industry tastemakers.
       
      Jean-Michel Basquiat was a beacon of innovation and social commentary, with his work not only featured in galleries and museums worldwide, but also igniting a powerful conversation on cultural complexities. Artestar and The Estate of Jean-Michel Basquiat continue to honor his prolific legacy by showcasing his art and its underlying messages, striving to engage with audiences worldwide to ensure his visionary work remains accessible and influential.
       
      “The ability to bring Basquiat’s iconic artwork directly into your home with Samsung Art Store is an exciting opportunity for global audiences to experience his work in a new and powerful way,” said David Stark, Founder and President of Artestar, the international brand licensing and consulting agency representing the Estate of Jean-Michel Basquiat. “Basquiat’s work continues to spark important conversations and encourages us to look at our worlds differently. This partnership on The Frame’s digital canvas allows his pieces to be experienced in anyone’s home, helping to share his work and honor his legacy.”
       
      The new collection features unique pieces from throughout Basquiat’s career. Among the works available to Art Store subscribers are Bird on Money (1982), a stunning tribute to Charlie Parker. Also included is Boy and Dog in a Johnnypump (1982), King Zulu (1986), which offers a large color block of blue in his more refined late style; and a dual portrait with Andy Warhol, Dos Cabezas (1982), which like many of his works pulls inspiration from his Puerto Rican heritage.
       
      This body of work was curated specifically for Samsung Art Store, adapted for a 16×9 format and were chosen based on their ability to be reproduced accurately, in keeping with Basquiat’s legacy.
       
      Jean-Michel Basquiat emerged as one of the most significant artists of the 20th century, his work rich with themes of heritage, identity and the human experience. Beginning his career as a graffiti artist in New York City under the pseudonym SAMO, Basquiat later transitioned to canvas to express his unique blend of symbolic, abstract and figurative styles. His art, characterized by intense colors, dynamic figures and cryptic texts, delves into topics such as societal power structures, racial inequality and the quest for identity. Basquiat’s impact was monumental, leaving a lasting legacy in the art world that explores social issues through his interest in pop culture and his own deeply refined neo-expressionist style.
       
      ▲ Mitchell Crew (1983), shown on The Frame via Samsung Art Store
       
      Since its founding in 2019, Samsung Art Store has been committed to bringing art from the world’s most renowned museums and important artists into homes across the world. The addition of the Basquiat collection significantly broadens the range of contemporary American artists whose works are now globally accessible for display.
       
      “Jean-Michel Basquiat’s work stands completely alone in the history of contemporary art, which is why it was essential that some of his most brilliant pieces were represented in Samsung Art Store,” said Daria Greene, Global Curator at Samsung Art Store. “Basquiat’s preeminent place in our culture and unique message to the world is as necessary today as it ever was, and we’re so proud to help share that message and expand on his legacy.”
       
      Basquiat’s work has been celebrated with numerous retrospectives and is held in prestigious collections globally, including those of the Museum of Modern Art, New York; The Metropolitan Museum of Art, New York; The Whitney Museum of American Art, New York; The Menil Collection, Houston; and the Museum of Contemporary Art, Los Angeles. His work continues to inspire new generations, embodying a bridge between street art and high art and challenging societal norms.
       
       
      Explore Thousands of Works From Artists and Institutions Around the World
      Alongside these new Basquiat pieces, viewers can explore thousands of additional artworks from masters such as Dalí and Van Gogh in Samsung Art Store,1 available for instant display on The Frame. Additionally, in Samsung’s Art Store you will find work from major global institutions including The Metropolitan Museum of Art, Tate Collection, the National Palace Museum in Taiwan, the Prado Museum in Madrid and the Belvedere Museum in Vienna.
       
      Samsung also recently refreshed The Frame line-up, with the new series now available for purchase. The 2024 line-up offers Pantone Art Validated Colors, so that every piece of art appears even more realistic, plus new Samsung Art Store – Streams, a complimentary set of regularly curated artworks sampled from Samsung Art Store. The Frame is even more energy efficient when in Art Mode, automatically adjusting the refresh rate so you can enjoy high-quality art, while conserving energy.2
       
       
      ABOUT JEAN-MICHEL BASQUIAT
      Jean-Michel Basquiat is one of the best-known artists of his generation and is widely considered one of the most important artists of the 20th century. His career in art spanned the last 1970s through the 1980s until his death in 1988 at the age of 27. Basquiat’s works are edgy and raw, and through a bold sense of color and composition, he maintains a fine balance between seemingly contradictory forces such as control and spontaneity, menace and wit, urban imagery, and primitivism.
       
      ABOUT ARTESTAR
      This partnership was done in collaboration with Artestar, a global licensing agency and creative consultancy representing high-profile artists, photographers, designers and creatives. Artestar connects brands with artists — curating and managing some of the world’s most recognizable creative collaborations. Learn more at artestar.com.
       
       
      1 A single user subscription for Art Store costs $4.99/month or $49.90/year.
      2 This feature applies to the 55’’ display and above.
      View the full article
    • By Samsung Newsroom
      Samsung Electronics today announced that it has been named the number one signage manufacturer for the fifteenth consecutive year by market research firm Omdia, once again demonstrating its leadership in the global digital signage market.1
       
      According to Omdia, in 2023 Samsung not only led the global signage market with a 33% market share, but also sold over 2 million units — a record-breaking number for the company.2
       
      “Achieving first place in the global display signage market for 15 consecutive years reflects our commitment to innovation and our ability to adapt to evolving market conditions and the needs of our customers,” said Hoon Chung, Executive Vice President of Visual Display Business at Samsung Electronics. “We will continue to provide the highest value to our customers by offering specialized devices, solutions and services that address their diverse needs.”
       
      Samsung Electronics is regularly introducing differentiated signage products that meet various business environment needs.
       
      The Wall, the world’s first modular display with micro LED technology. Thanks to its modular format, The Wall allows customers to adjust the sign’s size, ratio and shape based on preference and use case. Smart Signage, which provides an excellent sense of immersion with its ultra-slim profile and uniform bezel design. Outdoor Signage tailored for sports, landmark markets, and electric vehicle charging stations. The screens in the Outdoor Signage portfolio are designed for clear visibility in any weather environment. Samsung Interactive Display, an e-board optimized for the education market that puts educational tools at the fingertips of educators and students.  
      The expansion of The Wall lineup is a clear indication of Samsung’s innovations and leading technology. Products like The Wall All-in-One and The Wall for Virtual Production were chosen by customers for their exceptional convenience and unique use cases, while The Wall has been selected as the display of choice for luxury hotels like Atlantis The Royal in Dubai and Hilton Waikiki Beach in Hawaii.
       
      Samsung’s leadership in the digital signage industry can be attributed to the company’s commitment to product and service innovation. For example, the introduction of the world’s first transparent Micro LED display in January was noted by industry experts as the next generation of commercial display, earning accolades such as “Most Mind-Blowing LED” and “Best Transparent Display” from the North American AV news outlet, rAVe.
       

       
      The recent introduction of the Samsung Visual eXperience Transformation (VXT) platform further demonstrates Samsung’s commitment to display innovation. This cloud-native platform combines content and remote signage operations on a single, secure platform, offering services and solutions that go beyond just hardware while ensuring seamless operation and management for users.
       
      Looking ahead, the global display signage market is poised for rapid growth, with an expected annual increase of 8% leading to a projected market size of $24.6 billion by 2027, up from $14 billion in 2020.3
       
       
      1 Omdia Q4 2023 Public Display Report; Based on sales volume. Note: consumer TVs are excluded.
      2 Omdia Q4 2023 Public Display Report; Based on sales volume. Note: consumer TVs are excluded.
      3 According to the combined LCD and LED signage sales revenue. Omdia Q4 2023 Public Displays Market Tracker (excluding Consumer TV), Omdia Q4 LED Video Displays Market Tracker.
      View the full article
    • By Samsung Newsroom
      Samsung Electronics cemented its position as the global leader of the commercial display market, defending marking the largest global share for 15 consecutive years.1
       
      Having entered the commercial display market with a full B2B signage in 2008, Samsung continues to make history of digital signage with consistent technological innovation, differentiated solutions, and market leadership.
       
      Samsung started by achieving first place in global market share of digital signage in 2009. Then in 2012, Samsung opened the LCD renaissance by introducing two transparent LCD models. In 2017, the world’s first cinema LED, Onyx, was unveiled, presenting a new standard for theater screens with unbelievable picture quality and infinite contrast ratio.
       
      Over a decade and a half of “firsts” has led to myriad breakthroughs in digital signage. The world’s first modular display “The Wall,” introduced in 2018, has freely adjustable screen size and shape, expanding the scope of digital signage to various spaces, like art museums and department stores.
       
      As demand for immersive content increased, Samsung created a new version of “The Wall” exclusively for virtual production studios in 2023. With ultimate picture quality, it overcomes the challenges of physical on-site sets and leads to a reduction in production time and cost. The Wall for Virtual Production continues to change the landscape of the content production with a top-tier customizable solution.
       
      Here’s a look at the footsteps of Samsung Signage, which has been solidifying its #1 position globally for 15 consecutive years2 with innovative display technology.
       

       
       
      1, 2 Omdia Q4 2023 Public Display Report; Based on sales volume. Note: consumer TVs are excluded.
      View the full article
    • By Samsung Newsroom
      Samsung Electronics has held its ground as the leader in the global soundbar market for ten consecutive years, from 2014 through 2023, according to the annual report from FutureSource Consulting. The latest data, released on February 28, highlights Samsung’s continuous market leadership, with a 20.3% market share and an 18.8% contribution to the industry’s sales volume in 2023.
       

       
      Samsung has continuously raised the bar for home entertainment systems over the years, earning its soundbars a reputation for superior sound quality and groundbreaking innovation. Signature features such as Q-Symphony and SpaceFit Sound have revolutionized the listening experience, offering users a deeply immersive soundscape that is finely tuned to their listening environments.
       
      This standard of excellence has been recognized by industry experts and reviewers, with T3 awarding the HW-Q990C “Best Soundbar” title for its immersive audio and “exceptional object-based sonics,” and HomeTheaterReview giving the soundbar an “Editor’s Choice” distinction and commenting: “It sounds excellent, regardless of what type of content you send its way.”
       
      This year, Samsung continues to push the boundaries with its soundbar lineup, introducing enhanced AI audio features and connectivity options to captivate consumers and home theater enthusiasts alike.
       
      ▲ Samsung Electronics’ 2024 flagship Q-series soundbar HW-Q990D further pushes the boundaries of immersive home audio experience
       
      The flagship Q-series soundbar, HW-Q990D, offers impressive 11.1.4-channel surround sound and an upgraded Q-Symphony feature. Powered by AI, the device analyzes and synchronizes voice channels for clear dialogues and immersive soundscape across all speakers. Paired with SpaceFit Sound Pro for customized audio calibration, the soundbar also ensures an immersive experience in any space, while HDMI 2.1 and 4K/120Hz passthrough provides connectivity options that meets the demands of modern home entertainment systems.
       
      “We are thrilled to once again be acknowledged as the market leader in soundbars, a milestone that reflects the positive feedback from our customers over the years,” said Cheolgi Kim, EVP of Visual Display Business at Samsung Electronics. “Building on this success, we will continue to push the boundaries of home entertainment with superior sound quality and advanced connectivity features, leveraging AI-based sound technology to strengthen the consumer experience and Samsung’s position in the global market.”
       
      For more information, visit https://www.samsung.com.
      View the full article





×
×
  • Create New...