Skip to content

Commit 0139270

Browse files
committed
Merge branch 'gz-rendering7' into mjcarroll/anchor_virtual
Signed-off-by: Michael Carroll <[email protected]>
2 parents 7adabf0 + 305f57b commit 0139270

File tree

3 files changed

+95
-6
lines changed

3 files changed

+95
-6
lines changed

test/integration/camera.cc

+21-6
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ TEST_F(CameraTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(Visibility))
511511
}
512512

513513
/////////////////////////////////////////////////
514-
TEST_F(CameraTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(ShaderSelection))
514+
TEST_F(CameraTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(ShaderSelection))
515515
{
516516
CHECK_UNSUPPORTED_ENGINE("optix");
517517
// This test checks that custom shaders are being rendering correctly in
@@ -534,12 +534,27 @@ TEST_F(CameraTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(ShaderSelection))
534534

535535
std::string vertexShaderFile;
536536
std::string fragmentShaderFile;
537-
if (this->engineToTest == "ogre2")
537+
538+
if (this->engine->Name() == "ogre2")
538539
{
539-
vertexShaderFile = "simple_color_330_vs.glsl";
540-
fragmentShaderFile = "simple_color_330_fs.glsl";
540+
switch(this->engine->GraphicsAPI())
541+
{
542+
case GraphicsAPI::OPENGL:
543+
case GraphicsAPI::VULKAN:
544+
vertexShaderFile = "simple_color_330_vs.glsl";
545+
fragmentShaderFile = "simple_color_330_fs.glsl";
546+
break;
547+
case GraphicsAPI::METAL:
548+
vertexShaderFile = "simple_color_vs.metal";
549+
fragmentShaderFile = "simple_color_fs.metal";
550+
break;
551+
case GraphicsAPI::DIRECT3D11:
552+
default:
553+
GTEST_FAIL() << "Unsupported graphics API for this test.";
554+
break;
555+
}
541556
}
542-
else if (this->engineToTest == "ogre")
557+
else if (this->engine->Name() == "ogre")
543558
{
544559
vertexShaderFile = "simple_color_vs.glsl";
545560
fragmentShaderFile = "simple_color_fs.glsl";
@@ -616,7 +631,7 @@ TEST_F(CameraTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(ShaderSelection))
616631

617632
// Currently, only ogre2 supports segmentation cameras
618633
SegmentationCameraPtr segmentationCamera;
619-
if (this->engineToTest == "ogre2")
634+
if (this->engine->Name() == "ogre2")
620635
{
621636
// Create segmentation camera
622637
// segmentation material switching may also affect shader materials
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (C) 2022 Open Source Robotics Foundation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
#include <metal_stdlib>
19+
using namespace metal;
20+
21+
22+
fragment float4 main_metal
23+
(
24+
)
25+
{
26+
return float4(1, 0, 0, 1);
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (C) 2022 Open Source Robotics Foundation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
#include <metal_stdlib>
19+
using namespace metal;
20+
21+
struct VS_INPUT
22+
{
23+
float4 position [[attribute(VES_POSITION)]];
24+
};
25+
26+
struct PS_INPUT
27+
{
28+
float4 gl_Position [[position]];
29+
};
30+
31+
struct Params
32+
{
33+
float4x4 worldviewproj_matrix;
34+
};
35+
36+
vertex PS_INPUT main_metal
37+
(
38+
VS_INPUT input [[stage_in]],
39+
constant Params &p [[buffer(PARAMETER_SLOT)]]
40+
)
41+
{
42+
PS_INPUT outVs;
43+
44+
outVs.gl_Position = ( p.worldviewproj_matrix * input.position ).xyzw;
45+
46+
return outVs;
47+
}

0 commit comments

Comments
 (0)