Quantcast
Jump to content


Recommended Posts

Posted

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



  • 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 that The Premiere 8K, the company’s flagship premium projector, has received the industry’s first 8K Association (8KA) certification for 8K projectors. This recognition underscores Samsung’s leadership in projection technology while setting a new benchmark for the industry.
       
      “The Premiere 8K receiving the industry’s first 8KA certification is a major milestone as it officially demonstrates the new potential of projector technology.” said Taeyoung Son, Executive Vice President of Visual Display Business at Samsung Electronics. “We are committed to expanding the 8K ecosystem by continuously and extensively integrating new technologies.”
       
       
      Raising the Bar for 8K Projection Standards

       
      The 8KA is a global consortium of leading technology companies dedicated to advancing the adoption and standardization of 8K technology. On Dec 10, the organization introduced its New Projector certification program for 8K projectors, a significant step in the development of the 8K ecosystem.
       
      The 8KA certification evaluates a comprehensive set of standards critical to delivering an immersive viewing experience. These include resolution (7680 x 4320), brightness, contrast and color gamut to ensure vivid detail in both highlights and shadows. The criteria also encompass high dynamic range (HDR) for enhanced visual depth, 8K upscaling to refine lower-resolution content and immersive audio capabilities that support the latest formats for synchronized, high-quality sound that matches 8K’s stunning picture quality.
       
      Samsung’s The Premiere 8K excelled across all these categories, becoming the first in the industry to receive the certification.
       
       
      Bringing Unmatched Immersion to the Home Cinema

       
      Unveiled at CES 2024, The Premiere 8K transforms home entertainment with groundbreaking features and cutting-edge technology. It is the first projector to offer 8K wireless connectivity, enabling seamless streaming without complex setups. Using ultra-short throw (UST) technology with advanced aspherical mirrors, it delivers stunning, high-resolution visuals from a short distance, eliminating the need for ceiling mounts or additional installations.
       
      The Premiere 8K is designed to deliver a truly immersive experience. With 4,500 ISO Lumens of brightness, it produces vibrant, lifelike visuals — even in well-lit spaces — while its Sound-on-Screen technology integrates the top speaker module and software algorithms for an immersive sound experience.
       
      With this 8KA certification, Samsung has reaffirmed its leadership in display innovation and further solidified its reputation as a pioneer in ultra-premium technology.
      View the full article
    • By mramnesia97
      My Samsung Smart TV's (Model Code: QE55Q80AATXXC) app window is completely broken. I'm trying to enable developer mode but as soon as I enter "Apps" the window is frozen. I cannot scroll or click on anything. I can activate to press the 123 digits, but nothing happens when I try to input 1,2,3,4,5
      I've tried resetting the TV completely, unplugged it, cleared cache and everything else I can think off.
      What could possibly cause the Apps drawer to not work and be completely frozen?
    • By Samsung Newsroom
      Samsung is expanding its partnership with Art Basel to Art Basel Miami Beach. Following the debut as Art Basel’s first-ever Official Visual Display partner in Basel, Switzerland earlier this year, complete with an immersive Collectors Lounge experience. Through this unique partnership, Samsung is also launching a new initiative with Art Basel to bring curated collections of contemporary artworks from Art Basel’s renowned exhibiting galleries exclusively to the Samsung Art Store. A new collection will be shared once a quarter with the first collection launching today.
       
      ▲ Fred Tomaselli’s Irwin’s Garden (detail) (2023) shown on The Frame by Samsung. Photo: Samsung
       
      The Samsung Art Store is available on The Frame, the best-selling lifestyle TV from Samsung that doubles as a piece of art. Subscribers around the world can experience gallery highlights from Art Basel, which joins other renowned collections such as those from The Metropolitan Museum of Art, The Museum of Modern Art and The Musée d’Orsay available on the Samsung Art Store. The latest partnership with Art Basel underscores Samsung’s commitment to making world-class art accessible to anyone with The Frame through its innovative platform. 
       
       
      Samsung Art Store Subscribers Get an Exclusive Look
      Art Basel Miami Beach is the premier global art fair of the Americas with cultural significance attracting thousands of art enthusiasts every year. For the first time, this exclusive experience is being delivered directly to the screens of millions of people through The Frame.
       
      Ahead of Art Basel Miami Beach, Samsung Art Store subscribers will have access to a curated collection of 15+ select works from Art Basel’s galleries, some of which will be displayed at the highly anticipated fair, taking place from December 6-8, 2024 at the Miami Beach Convention Center. The collection features pieces from international contemporary galleries, including James Cohan, Kasmin, moniquemeloche, mor charpentier, Nara Roesler, Roberts Projects and Tina Kim, offering subscribers a unique, front-row look at some of Art Basel’s incredible works of art.
       
      ▲ Candida Alvarez’s Mostly Clear (detail) (2023) shown on The Frame by Samsung. Photo: Samsung
       
      Founded in 1970 by gallerists from Basel, Art Basel is the world’s premier art fair for modern and contemporary art. This year in Miami Beach, Art Basel will bring together 286 leading international galleries from 38 countries to present artworks of the highest quality across all media — from painting and sculpture to photography and digital works. Art Basel will once again reaffirm its unparalleled position as a platform for discovery and encounters that drive the art world.
       
      “Art Basel’s mission is to power the world of art by connecting leading artists and galleries with art loving audiences,” said Noah Horowitz, CEO of Art Basel. “Our collaboration with Samsung allows us to extend that reach like never before by broadening access to leading galleries and significant works from established artists to a new generation of emerging talents.”
       
      Yong Su Kim, EVP and Global Head of Video Services and Partnerships at Samsung, echoed the excitement surrounding this partnership. “Art Basel represents the pinnacle of contemporary art, and we are thrilled to amplify that experience with leading display technology that brings art to millions of people,” Kim said. “Through the Samsung Art Store and the lifelike visuals of The Frame, we are making it possible for anyone to experience Art Basel and take part in an iconic cultural moment.”
       
       
      Samsung Art Store Collectors Lounge to Feature Industry Panels, Interactive Activation and More
      As the Official Display Partner of Art Basel Miami Beach, Samsung is hosting a dedicated Samsung Art Store Collectors Lounge from December 4-8 under the concept, “Bringing Art Home,” where attendees can enjoy remarkable artworks on The Frame’s museum-worthy display. In addition, visitors will see The Frame showcased with unique bezels in various colors and designs from DecoTVFrames, an official Samsung partner exclusively available for The Frame.
       
      The Frame will also be installed throughout the fair to present visitors with a variety of vivid screen experiences.
       
      In addition to its dynamic Collectors Lounge experience, Samsung is hosting a series of panel discussions featuring influential voices from the contemporary art world. These sessions include:
       
      Celebrating Women in Art and Technology — Innovation and Expression
      An engaging panel led by Daria Greene, Head of Global Curation at Samsung. This discussion celebrates the journey of female artists and innovators who are redefining the intersection of art and technology. Gain insights into how digital platforms are amplifying voices and breaking new ground in contemporary art. The Future of Digital Art — Innovation, Rights and Connectivity
      Explore the future of digital art in this thought-provoking panel, moderated by Maya Harris, Head of Business Development and Strategic Partnerships at Samsung. This session delves into how technology is reshaping artistic rights, accessibility and the ways institutions and artists connect with global audiences.  
      As the home for Samsung Art Store, The Frame has been refreshed in 2024 to deliver an even more complete artistic and aesthetic experience. That includes Pantone Validated ArtfulColor Certification,1 the industry leading color experts. The Frame is the world’s first and only art TV to achieve this validation, ensuring natural and realistic visuals that wouldn’t look out of place in a gallery. It also sports an Anti-Reflection with Matte Display, helping you limit light distractions so your artwork appears even more true-to-life. The Frame hangs just like a picture flush against the wall and is available in class sizes ranging from 32 to 85 inches.
       
      The Frame also delivers value-add features that you can only find from Samsung — the #1 global TV brand for 18 years and counting.2 Samsung technology makes everything you watch look clearer and crisper, while you enjoy access to 2,700+ free channels, including 400+ premium channels on Samsung TV Plus.3 You can also game without a console through Samsung Gaming Hub,4 use your TV as your smart home hub and ensure your personal data is protected by Samsung Knox security.
       
       
      1 Pantone company provides a universal language of color, called Pantone Matching System, that enables color-critical decisions through every stage of the workflow for brands and manufacturers.
      2 Source: Omdia, Jan 2024. Results are not an endorsement of Samsung. Any reliance on these results is at the third party’s own risk.
      3 Available for free on Samsung Smart TVs released after 2016, Galaxy devices, Smart Monitors, Family Hub refrigerators and the web.
      4 Available games and content may vary by country and model and are subject to change without notice. Certain games require a separate controller. Internet connection and subscription may be required. Requires a Samsung account.
      View the full article
    • By Alex
      Three weeks ago, the company released in India the Samsung Z1, its first smartphone powered by Tizen, a homegrown alternative to Google Inc.’s Android operating system.
       
      This week, Samsung is pushing the Samsung Z1 into Bangladesh, a neighbor of India with more than 150 million people and a similarly low rate of smartphone penetration.
       
      After several missteps and rethinks, Samsung’s strategy for its Tizen smartphones is taking a clear shape: the company is aiming the fledgling platform squarely at first-time smartphone users, many of whom may not even have a bank account. The Samsung Z1 is selling in India for about $90.
       
      To that end, Samsung has been touting the “lightweight” nature of the Tizen operating system, meaning that it requires relatively little computing power and can handle most tasks without requiring pricey high-end specifications.
       
      That same lightweight approach has also allowed Samsung to use Tizen as the platform for many of the devices it is hoping will populate its “connected home,” from televisions to smart watches and home appliances.
       
      Despite concerns that Samsung’s new smartphone would face stiff competition in India, where several local handset makers are touting low-end smartphones — some of them in partnership with Google — Samsung says that its Tizen smartphones have received “positive responses” there.
       
      Positive enough, it seems, to at least push Tizen into a second country.
       
      Source: http://blogs.wsj.com/digits/2015/02/06/samsung-extends-tizen-smartphone-to-bangladesh/





×
×
  • Create New...