Skip to content

Commit

Permalink
Merge branch 'gz-rendering7' into mjcarroll/ogre_depth_camera_segfault
Browse files Browse the repository at this point in the history
  • Loading branch information
mjcarroll authored Aug 18, 2022
2 parents 845480d + 305f57b commit 1bfcde2
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
*
*/

#include <gz/rendering/ogre2/Ogre2BoundinBoxCamera.hh>
#include <gz/rendering/ogre2/Ogre2BoundingBoxCamera.hh>
#include <ignition/rendering/config.hh>
27 changes: 21 additions & 6 deletions test/integration/camera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ TEST_F(CameraTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(Visibility))
}

/////////////////////////////////////////////////
TEST_F(CameraTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(ShaderSelection))
TEST_F(CameraTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(ShaderSelection))
{
CHECK_UNSUPPORTED_ENGINE("optix");
// This test checks that custom shaders are being rendering correctly in
Expand All @@ -534,12 +534,27 @@ TEST_F(CameraTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(ShaderSelection))

std::string vertexShaderFile;
std::string fragmentShaderFile;
if (this->engineToTest == "ogre2")

if (this->engine->Name() == "ogre2")
{
vertexShaderFile = "simple_color_330_vs.glsl";
fragmentShaderFile = "simple_color_330_fs.glsl";
switch(this->engine->GraphicsAPI())
{
case GraphicsAPI::OPENGL:
case GraphicsAPI::VULKAN:
vertexShaderFile = "simple_color_330_vs.glsl";
fragmentShaderFile = "simple_color_330_fs.glsl";
break;
case GraphicsAPI::METAL:
vertexShaderFile = "simple_color_vs.metal";
fragmentShaderFile = "simple_color_fs.metal";
break;
case GraphicsAPI::DIRECT3D11:
default:
GTEST_FAIL() << "Unsupported graphics API for this test.";
break;
}
}
else if (this->engineToTest == "ogre")
else if (this->engine->Name() == "ogre")
{
vertexShaderFile = "simple_color_vs.glsl";
fragmentShaderFile = "simple_color_fs.glsl";
Expand Down Expand Up @@ -616,7 +631,7 @@ TEST_F(CameraTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(ShaderSelection))

// Currently, only ogre2 supports segmentation cameras
SegmentationCameraPtr segmentationCamera;
if (this->engineToTest == "ogre2")
if (this->engine->Name() == "ogre2")
{
// Create segmentation camera
// segmentation material switching may also affect shader materials
Expand Down
27 changes: 27 additions & 0 deletions test/media/materials/programs/simple_color_fs.metal
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (C) 2022 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#include <metal_stdlib>
using namespace metal;


fragment float4 main_metal
(
)
{
return float4(1, 0, 0, 1);
}
47 changes: 47 additions & 0 deletions test/media/materials/programs/simple_color_vs.metal
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (C) 2022 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#include <metal_stdlib>
using namespace metal;

struct VS_INPUT
{
float4 position [[attribute(VES_POSITION)]];
};

struct PS_INPUT
{
float4 gl_Position [[position]];
};

struct Params
{
float4x4 worldviewproj_matrix;
};

vertex PS_INPUT main_metal
(
VS_INPUT input [[stage_in]],
constant Params &p [[buffer(PARAMETER_SLOT)]]
)
{
PS_INPUT outVs;

outVs.gl_Position = ( p.worldviewproj_matrix * input.position ).xyzw;

return outVs;
}

0 comments on commit 1bfcde2

Please sign in to comment.