Skip to content

Commit f4db193

Browse files
committed
6.2.3
- Marked samples that use the GL_VIV_direct_texture extension but was not marked as such. - SmoothScroll should now scroll on displays that are too small to show the entire text being shown - Fix out-of-bound R/W in gaussian_filter.cl - FslUtil.OpenCL.ContextEx added new constructor and reset method.
1 parent 5bcee47 commit f4db193

File tree

14 files changed

+171
-22
lines changed

14 files changed

+171
-22
lines changed

DemoApps/GLES2/DeBayer/Fsl.gen

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
<FslBuildGen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../FslBuildGen.xsd">
33
<Executable Name="GLES2.DeBayer" NoInclude="true" CreationYear="2015">
44
<Default.Platform.Supported Value="false"/>
5+
<Requirement Name="GL_VIV_direct_texture" Type="extension" Extends="OpenGLES"/>
6+
<!-- While this demo technically only require the GL_VIV_direct_texture extension, its likely to only exist on Vivante GPU's -->
7+
<Requirement Name="HW_GPU_VIVANTE" Type="feature"/>
58
<ImportTemplate Name="DemoAppGLES2"/>
69
<Dependency Name="Gst"/>
710
</Executable>

DemoApps/GLES2/DirectMultiSamplingVideoYUV/Fsl.gen

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
<FslBuildGen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../FslBuildGen.xsd">
33
<Executable Name="GLES2.DirectMultiSamplingVideoYUV" NoInclude="true" CreationYear="2014">
44
<Default.Platform.Supported Value="false"/>
5+
<Requirement Name="GL_VIV_direct_texture" Type="extension" Extends="OpenGLES"/>
6+
<!-- While this demo technically only require the GL_VIV_direct_texture extension, its likely to only exist on Vivante GPU's -->
7+
<Requirement Name="HW_GPU_VIVANTE" Type="feature"/>
58
<ImportTemplate Name="DemoAppGLES2"/>
69
<Dependency Name="Gst"/>
710
</Executable>

DemoApps/GLES2/S09_VIV_direct_texture/Fsl.gen

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<Executable Name="GLES2.S09_VIV_direct_texture" NoInclude="true" CreationYear="2014">
44
<Default.Platform.Supported Value="false"/>
55
<Requirement Name="GL_VIV_direct_texture" Type="extension" Extends="OpenGLES"/>
6+
<!-- While this demo technically only require the GL_VIV_direct_texture extension, its likely to only exist on Vivante GPU's -->
7+
<Requirement Name="HW_GPU_VIVANTE" Type="feature"/>
68
<ImportTemplate Name="DemoAppGLES2"/>
79
<Platform Name="Yocto" Supported="true"/>
810
</Executable>

DemoApps/GLES2/VIVDirectTextureMultiSampling/Fsl.gen

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
<FslBuildGen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../FslBuildGen.xsd">
33
<Executable Name="GLES2.VIVDirectTextureMultiSampling" NoInclude="true" CreationYear="2016">
44
<Default.Platform.Supported Value="false"/>
5+
<Requirement Name="GL_VIV_direct_texture" Type="extension" Extends="OpenGLES"/>
6+
<!-- While this demo technically only require the GL_VIV_direct_texture extension, its likely to only exist on Vivante GPU's -->
7+
<Requirement Name="HW_GPU_VIVANTE" Type="feature"/>
58
<ImportTemplate Name="DemoAppGLES2"/>
69
<Platform Name="Yocto" Supported="true"/>
710
</Executable>

DemoApps/GLES3/DirectMultiSamplingVideoYUV/Fsl.gen

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
<FslBuildGen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../FslBuildGen.xsd">
33
<Executable Name="GLES3.DirectMultiSamplingVideoYUV" NoInclude="true" CreationYear="2014">
44
<Default.Platform.Supported Value="false"/>
5-
5+
<Requirement Name="GL_VIV_direct_texture" Type="extension" Extends="OpenGLES"/>
6+
<!-- While this demo technically only require the GL_VIV_direct_texture extension, its likely to only exist on Vivante GPU's -->
7+
<Requirement Name="HW_GPU_VIVANTE" Type="feature"/>
68
<ImportTemplate Name="DemoAppGLES3"/>
79
<Dependency Name="Gst"/>
810
</Executable>

DemoApps/GLES3/OpenCLGaussianFilter/Content/gaussian_filter.cl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,26 @@ __kernel void gaussian_filter ( __global uchar *input,
3636
{1.0/16.0, 2.0/16.0, 1.0/16.0}
3737
};
3838

39-
if ((x < 0) || (y < 0) || (x > (width -1)) || (y > (height -1)))
39+
if ((id - width -1) < 0 || (id + width + 1) >= (width * height - 1))
4040
{
4141
output[id] = input[id];
4242
return;
4343
}
4444

45+
if (channels == 3)
46+
{
47+
if ((id1 - width -1) < 0 || (id1 + width + 1) >= (width * height - 1))
48+
{
49+
output[id] = input[id];
50+
return;
51+
}
52+
if ((id2 - width -1) < 0 || (id2 + width + 1) >= (width * height - 1))
53+
{
54+
output[id] = input[id];
55+
return;
56+
}
57+
}
58+
4559
if (channels == 1)
4660
{
4761
sum = input[id - width - 1] * kernel_weights[0][0];

DemoApps/GLES3/RenderToTexture/Fsl.gen

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
<Platform Name="Yocto" Supported="true">
99
<Dependency Name="G2D"/>
1010
<Requirement Name="GL_VIV_direct_texture" Type="extension" Extends="OpenGLES"/>
11+
<!-- While this demo technically only require the GL_VIV_direct_texture extension, its likely to only exist on Vivante GPU's -->
12+
<Requirement Name="HW_GPU_VIVANTE" Type="feature"/>
1113
</Platform>
1214
</Executable>
1315
</FslBuildGen>

DemoApps/GLES3/S09_VIV_direct_texture/Fsl.gen

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<Executable Name="GLES3.S09_VIV_direct_texture" NoInclude="true" CreationYear="2014">
44
<Default.Platform.Supported Value="false"/>
55
<Requirement Name="GL_VIV_direct_texture" Type="extension" Extends="OpenGLES"/>
6+
<!-- While this demo technically only require the GL_VIV_direct_texture extension, its likely to only exist on Vivante GPU's -->
7+
<Requirement Name="HW_GPU_VIVANTE" Type="feature"/>
68
<ImportTemplate Name="DemoAppGLES3"/>
79
<Platform Name="Yocto" Supported="true"/>
810
</Executable>

DemoApps/Shared/UI/SmoothScroll/source/Shared/UI/SmoothScroll/Shared.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,27 +239,34 @@ namespace Fsl
239239
Vector2 position3(std::round(m_position1) + static_cast<float>(rectMiddleBottomPx.RawLeft()), static_cast<float>(rectMiddleBottomPx.RawTop()));
240240

241241
const int32_t linesHeightPx = bitmapFont.LineSpacingPx().RawValue() * 4;
242-
const int32_t linewidth = bitmapFont.MeasureString(LocalConfig::TextLine0).RawWidth();
242+
const int32_t lineWidth = bitmapFont.MeasureString(LocalConfig::TextLine0).RawWidth();
243243

244-
if (m_position0 < static_cast<float>(rectTopLeftPx.RawTop()))
244+
const auto partialLineHeight = static_cast<int32_t>(std::round(static_cast<float>(linesHeightPx) * 0.90f));
245+
const auto scrollLimitTop = static_cast<float>(rectTopLeftPx.RawTop() - partialLineHeight);
246+
const auto scrollLimitBottom = static_cast<float>(rectTopLeftPx.RawBottom() - (linesHeightPx - partialLineHeight));
247+
248+
if (m_position0 < scrollLimitTop)
245249
{
246-
m_position0 = static_cast<float>(rectTopLeftPx.RawTop());
250+
m_position0 = scrollLimitTop;
247251
m_direction0 = 1;
248252
}
249-
if (m_position0 > static_cast<float>(rectTopLeftPx.RawBottom() - linesHeightPx))
253+
if (m_position0 > scrollLimitBottom)
250254
{
251-
m_position0 = static_cast<float>(rectTopLeftPx.RawBottom() - linesHeightPx);
255+
m_position0 = scrollLimitBottom;
252256
m_direction0 = -1;
253257
}
254258

255-
if (m_position1 < static_cast<float>(rectMiddleBottomPx.RawLeft()))
259+
const auto partialLineWidth = static_cast<int32_t>(std::round(static_cast<float>(lineWidth) * 0.90f));
260+
const auto scrollLimitLeft = static_cast<float>(rectMiddleBottomPx.RawLeft() - partialLineWidth);
261+
const auto scrollLimitRight = static_cast<float>(rectMiddleBottomPx.RawRight() - (lineWidth - partialLineWidth));
262+
if (m_position1 < scrollLimitLeft)
256263
{
257-
m_position1 = static_cast<float>(rectMiddleBottomPx.RawLeft());
264+
m_position1 = scrollLimitLeft;
258265
m_direction1 = 1;
259266
}
260-
if (m_position1 > static_cast<float>(rectMiddleBottomPx.RawRight() - linewidth))
267+
if (m_position1 > scrollLimitRight)
261268
{
262-
m_position1 = static_cast<float>(rectMiddleBottomPx.RawRight() - linewidth);
269+
m_position1 = scrollLimitRight;
263270
m_direction1 = -1;
264271
}
265272

DemoFramework/FslUtil/OpenCL1_2/include/FslUtil/OpenCL1_2/ContextEx.hpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
// Make sure Common.hpp is the first include file (to make the error message as helpful as possible when disabled)
3535
#include <FslBase/Attributes.hpp>
36+
#include <FslBase/Span/ReadOnlySpan.hpp>
3637
#include <FslUtil/OpenCL1_2/Common.hpp>
3738
#include <RapidOpenCL1/Context.hpp>
3839
#include <CL/cl.h>
@@ -71,6 +72,16 @@ namespace Fsl::OpenCL
7172
// NOLINTNEXTLINE(misc-misplaced-const)
7273
explicit ContextEx(const cl_device_type deviceType, cl_device_id* pDeviceId = nullptr, const bool allowFallback = true);
7374

75+
//! @brief Create the requested resource
76+
//! @param contextPropertiesSpan the context properties to use (supply a empty one to use the default).
77+
//! If this span is not empty and contains a CL_CONTEXT_PLATFORM entry that is 0, then the entry will be patched with the right platformId.
78+
//! If this span is not empty and does not contain a CL_CONTEXT_PLATFORM then a CL_CONTEXT_PLATFORM entry will be added.
79+
//! @param pDeviceId the chosen device id (if nullptr this is ignored, else it will be assigned the chosen deviceId)
80+
//! @param allowFallback if the specified device type can't be found allow using a fallback of CL_DEVICE_TYPE_ALL
81+
// NOLINTNEXTLINE(misc-misplaced-const)
82+
explicit ContextEx(const ReadOnlySpan<cl_context_properties> contextPropertiesSpan, const cl_device_type deviceType,
83+
cl_device_id* pDeviceId = nullptr, const bool allowFallback = true);
84+
7485
//! @brief returns the managed handle and releases the ownership.
7586
[[nodiscard]] cl_context Release()
7687
{
@@ -99,6 +110,16 @@ namespace Fsl::OpenCL
99110
// NOLINTNEXTLINE(misc-misplaced-const)
100111
void Reset(const cl_device_type deviceType, cl_device_id* pDeviceId = nullptr, const bool allowFallback = true);
101112

113+
//! @brief Destroys any owned resources and then creates the requested one
114+
//! @param contextPropertiesSpan the context properties to use (supply a empty one to use the default).
115+
//! If this span is not empty and contains a CL_CONTEXT_PLATFORM entry that is 0, then the entry will be patched with the right platformId.
116+
//! If this span is not empty and does not contain a CL_CONTEXT_PLATFORM then a CL_CONTEXT_PLATFORM entry will be added.
117+
//! @param pDeviceId the chosen device id (if nullptr this is ignored, else it will be assigned the chosen deviceId)
118+
//! @param allowFallback if the specified device type can't be found allow using a fallback of CL_DEVICE_TYPE_ALL
119+
// NOLINTNEXTLINE(misc-misplaced-const)
120+
void Reset(const ReadOnlySpan<cl_context_properties> contextPropertiesSpan, const cl_device_type deviceType, cl_device_id* pDeviceId = nullptr,
121+
const bool allowFallback = true);
122+
102123
//! @brief Get the associated resource handle
103124
cl_platform_id GetPlatformId() const
104125
{
@@ -118,7 +139,9 @@ namespace Fsl::OpenCL
118139
}
119140

120141
private:
121-
void SelectDevice(cl_platform_id platformId, const std::vector<cl_device_id>& deviceIds, cl_device_id* pDeviceId);
142+
void SelectDevice(const ReadOnlySpan<cl_context_properties> contextPropertiesSpan, cl_platform_id platformId,
143+
const std::vector<cl_device_id>& deviceIds, cl_device_id* pDeviceId);
144+
std::vector<cl_context_properties> PatchProperties(cl_platform_id platformId, const ReadOnlySpan<cl_context_properties> contextPropertiesSpan);
122145
};
123146
}
124147

0 commit comments

Comments
 (0)