From 7b1a21d3dcf9f7fce366735b4432fc0d3b8edaa4 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Mon, 16 Dec 2024 18:02:13 -0800 Subject: [PATCH] Automated Code Change PiperOrigin-RevId: 706898760 --- .../rendering/opengl/egl_offscreen_context.cc | 18 ++++---- .../rendering/opengl/gl_program.cc | 44 ++++++++++--------- .../rendering/opengl/gl_render_targets.cc | 12 ++--- .../opengl/gl_shader_storage_buffer.cc | 8 ++-- .../rendering/opengl/rasterizer.cc | 16 +++---- .../rendering/opengl/rasterizer_op.cc | 39 ++++++++-------- .../opengl/rasterizer_with_context.cc | 18 ++++---- 7 files changed, 78 insertions(+), 77 deletions(-) diff --git a/tensorflow_graphics/rendering/opengl/egl_offscreen_context.cc b/tensorflow_graphics/rendering/opengl/egl_offscreen_context.cc index 307971fdd..2533307db 100644 --- a/tensorflow_graphics/rendering/opengl/egl_offscreen_context.cc +++ b/tensorflow_graphics/rendering/opengl/egl_offscreen_context.cc @@ -29,7 +29,7 @@ EGLOffscreenContext::EGLOffscreenContext(EGLContext context, EGLDisplay display, EGLOffscreenContext::~EGLOffscreenContext() { TF_CHECK_OK(Destroy()); } -tensorflow::Status EGLOffscreenContext::Create( +absl::Status EGLOffscreenContext::Create( std::unique_ptr* egl_offscreen_context) { constexpr std::array kDefaultConfigurationAttributes = { EGL_SURFACE_TYPE, @@ -56,7 +56,7 @@ tensorflow::Status EGLOffscreenContext::Create( kDefaultContextAttributes.data(), egl_offscreen_context); } -tensorflow::Status EGLOffscreenContext::Create( +absl::Status EGLOffscreenContext::Create( const int pixel_buffer_width, const int pixel_buffer_height, const EGLenum rendering_api, const EGLint* configuration_attributes, const EGLint* context_attributes, @@ -112,10 +112,10 @@ tensorflow::Status EGLOffscreenContext::Create( surface_cleanup.release(); *egl_offscreen_context = std::unique_ptr( new EGLOffscreenContext(context, display, pixel_buffer_surface)); - return tensorflow::Status(); + return absl::Status(); } -tensorflow::Status EGLOffscreenContext::Destroy() { +absl::Status EGLOffscreenContext::Destroy() { TF_RETURN_IF_ERROR(Release()); if (eglDestroyContext(display_, context_) == false) { return TFG_INTERNAL_ERROR("an error occured in eglDestroyContext."); @@ -127,19 +127,19 @@ tensorflow::Status EGLOffscreenContext::Destroy() { return TFG_INTERNAL_ERROR( "an error occured in TerminateInitializedEGLDisplay."); } - return tensorflow::Status(); + return absl::Status(); } -tensorflow::Status EGLOffscreenContext::MakeCurrent() const { +absl::Status EGLOffscreenContext::MakeCurrent() const { TFG_RETURN_IF_EGL_ERROR(eglMakeCurrent(display_, pixel_buffer_surface_, pixel_buffer_surface_, context_)); - return tensorflow::Status(); + return absl::Status(); } -tensorflow::Status EGLOffscreenContext::Release() { +absl::Status EGLOffscreenContext::Release() { if (context_ != EGL_NO_CONTEXT && context_ == eglGetCurrentContext()) { TFG_RETURN_IF_EGL_ERROR(eglMakeCurrent(display_, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)); } - return tensorflow::Status(); + return absl::Status(); } diff --git a/tensorflow_graphics/rendering/opengl/gl_program.cc b/tensorflow_graphics/rendering/opengl/gl_program.cc index a3e3a42f3..9a2c624c7 100644 --- a/tensorflow_graphics/rendering/opengl/gl_program.cc +++ b/tensorflow_graphics/rendering/opengl/gl_program.cc @@ -24,9 +24,9 @@ Program::Program(GLuint program_handle) : program_handle_(program_handle) {} Program::~Program() { glDeleteProgram(program_handle_); } -tensorflow::Status Program::CompileShader(const std::string& shader_code, - const GLenum& shader_type, - GLuint* shader_idx) { +absl::Status Program::CompileShader(const std::string& shader_code, + const GLenum& shader_type, + GLuint* shader_idx) { // Create an empty shader object. TFG_RETURN_IF_EGL_ERROR(*shader_idx = glCreateShader(shader_type)); if (*shader_idx == 0) @@ -59,10 +59,10 @@ tensorflow::Status Program::CompileShader(const std::string& shader_code, std::string(&info_log[0])); } shader_cleanup.release(); - return tensorflow::Status(); + return absl::Status(); } -tensorflow::Status Program::Create( +absl::Status Program::Create( const std::vector>& shaders, std::unique_ptr* program) { // Create an empty program object. @@ -99,37 +99,39 @@ tensorflow::Status Program::Create( program_cleanup.release(); // The content of shader_cleanups needs cleanup and hence is not released; see // https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glDeleteProgram.xhtml. - return tensorflow::Status(); + return absl::Status(); } -tensorflow::Status Program::Detach() const { +absl::Status Program::Detach() const { TFG_RETURN_IF_GL_ERROR(glUseProgram(0)); - return tensorflow::Status(); + return absl::Status(); } -tensorflow::Status Program::GetProgramResourceIndex( - GLenum program_interface, absl::string_view resource_name, - GLuint* resource_index) const { +absl::Status Program::GetProgramResourceIndex(GLenum program_interface, + absl::string_view resource_name, + GLuint* resource_index) const { TFG_RETURN_IF_EGL_ERROR(*resource_index = glGetProgramResourceIndex( program_handle_, program_interface, resource_name.data())); - return tensorflow::Status(); + return absl::Status(); } -tensorflow::Status Program::GetProgramResourceiv( +absl::Status Program::GetProgramResourceiv( GLenum program_interface, GLuint resource_index, int num_properties, const GLenum* properties, int num_property_value, GLsizei* length, GLint* property_value) const { TFG_RETURN_IF_EGL_ERROR(glGetProgramResourceiv( program_handle_, program_interface, resource_index, num_properties, properties, num_property_value, length, property_value)); - return tensorflow::Status(); + return absl::Status(); } -tensorflow::Status Program::GetResourceProperty( - const std::string& resource_name, GLenum program_interface, - int num_properties, const GLenum* properties, int num_property_value, - GLint* property_value) { +absl::Status Program::GetResourceProperty(const std::string& resource_name, + GLenum program_interface, + int num_properties, + const GLenum* properties, + int num_property_value, + GLint* property_value) { if (num_property_value != num_properties) return TFG_INTERNAL_ERROR("num_property_value != num_properties"); @@ -152,12 +154,12 @@ tensorflow::Status Program::GetResourceProperty( return TFG_INTERNAL_ERROR("length != num_properties: ", length, " != ", num_properties); - return tensorflow::Status(); + return absl::Status(); } -tensorflow::Status Program::Use() const { +absl::Status Program::Use() const { TFG_RETURN_IF_EGL_ERROR(glUseProgram(program_handle_)); - return tensorflow::Status(); + return absl::Status(); } } // namespace gl_utils diff --git a/tensorflow_graphics/rendering/opengl/gl_render_targets.cc b/tensorflow_graphics/rendering/opengl/gl_render_targets.cc index eba83bc06..c7e152213 100644 --- a/tensorflow_graphics/rendering/opengl/gl_render_targets.cc +++ b/tensorflow_graphics/rendering/opengl/gl_render_targets.cc @@ -38,12 +38,12 @@ RenderTargets::~RenderTargets() { glDeleteFramebuffers(1, &frame_buffer_); } -tensorflow::Status RenderTargets::BindFramebuffer() const { +absl::Status RenderTargets::BindFramebuffer() const { TFG_RETURN_IF_GL_ERROR(glBindFramebuffer(GL_FRAMEBUFFER, frame_buffer_)); - return tensorflow::Status(); + return absl::Status(); } -tensorflow::Status RenderTargets::CreateValidInternalFormat( +absl::Status RenderTargets::CreateValidInternalFormat( GLenum internalformat, GLsizei width, GLsizei height, std::unique_ptr* render_targets) { GLuint color_buffer; @@ -92,16 +92,16 @@ tensorflow::Status RenderTargets::CreateValidInternalFormat( gen_color_cleanup.release(); gen_depth_cleanup.release(); gen_frame_cleanup.release(); - return tensorflow::Status(); + return absl::Status(); } GLsizei RenderTargets::GetHeight() const { return height_; } GLsizei RenderTargets::GetWidth() const { return width_; } -tensorflow::Status RenderTargets::UnbindFrameBuffer() const { +absl::Status RenderTargets::UnbindFrameBuffer() const { TFG_RETURN_IF_GL_ERROR(glBindFramebuffer(GL_FRAMEBUFFER, 0)); - return tensorflow::Status(); + return absl::Status(); } } // namespace gl_utils diff --git a/tensorflow_graphics/rendering/opengl/gl_shader_storage_buffer.cc b/tensorflow_graphics/rendering/opengl/gl_shader_storage_buffer.cc index b33575a06..366037c83 100644 --- a/tensorflow_graphics/rendering/opengl/gl_shader_storage_buffer.cc +++ b/tensorflow_graphics/rendering/opengl/gl_shader_storage_buffer.cc @@ -24,7 +24,7 @@ ShaderStorageBuffer::ShaderStorageBuffer(GLuint buffer) : buffer_(buffer) {} ShaderStorageBuffer::~ShaderStorageBuffer() { glDeleteBuffers(1, &buffer_); } -tensorflow::Status ShaderStorageBuffer::Create( +absl::Status ShaderStorageBuffer::Create( std::unique_ptr* shader_storage_buffer) { GLuint buffer; @@ -32,13 +32,13 @@ tensorflow::Status ShaderStorageBuffer::Create( TFG_RETURN_IF_EGL_ERROR(glGenBuffers(1, &buffer)); *shader_storage_buffer = std::unique_ptr(new ShaderStorageBuffer(buffer)); - return tensorflow::Status(); + return absl::Status(); } -tensorflow::Status ShaderStorageBuffer::BindBufferBase(GLuint index) const { +absl::Status ShaderStorageBuffer::BindBufferBase(GLuint index) const { TFG_RETURN_IF_EGL_ERROR( glBindBufferBase(GL_SHADER_STORAGE_BUFFER, index, buffer_)); - return tensorflow::Status(); + return absl::Status(); } } // namespace gl_utils diff --git a/tensorflow_graphics/rendering/opengl/rasterizer.cc b/tensorflow_graphics/rendering/opengl/rasterizer.cc index 57120b350..d04349403 100644 --- a/tensorflow_graphics/rendering/opengl/rasterizer.cc +++ b/tensorflow_graphics/rendering/opengl/rasterizer.cc @@ -36,19 +36,19 @@ void Rasterizer::Reset() { for (auto&& buffer : shader_storage_buffers_) buffer.second.reset(); } -tensorflow::Status Rasterizer::Render(int num_points, - absl::Span result) { +absl::Status Rasterizer::Render(int num_points, absl::Span result) { return RenderImpl(num_points, result); } -tensorflow::Status Rasterizer::Render(int num_points, - absl::Span result) { +absl::Status Rasterizer::Render(int num_points, + absl::Span result) { return RenderImpl(num_points, result); } -tensorflow::Status Rasterizer::SetUniformMatrix( - const std::string& name, int num_columns, int num_rows, bool transpose, - absl::Span matrix) { +absl::Status Rasterizer::SetUniformMatrix(const std::string& name, + int num_columns, int num_rows, + bool transpose, + absl::Span matrix) { if (size_t(num_rows * num_columns) != matrix.size()) return TFG_INTERNAL_ERROR("num_rows * num_columns != matrix.size()"); @@ -98,5 +98,5 @@ tensorflow::Status Rasterizer::SetUniformMatrix( uniform_location, 1, transpose ? GL_TRUE : GL_FALSE, matrix.data())); // Cleanup the program; no program is active at this point. - return tensorflow::Status(); + return absl::Status(); } diff --git a/tensorflow_graphics/rendering/opengl/rasterizer_op.cc b/tensorflow_graphics/rendering/opengl/rasterizer_op.cc index e44de6d38..22e1d0da2 100644 --- a/tensorflow_graphics/rendering/opengl/rasterizer_op.cc +++ b/tensorflow_graphics/rendering/opengl/rasterizer_op.cc @@ -26,7 +26,7 @@ limitations under the License. #include "tensorflow/core/lib/core/errors.h" #include "tensorflow/core/lib/core/status.h" -static tensorflow::Status GetVariablesRank( +static absl::Status GetVariablesRank( ::tensorflow::shape_inference::InferenceContext* c, tensorflow::int32* rank) { std::vector variable_names, variable_kinds; @@ -68,7 +68,7 @@ static tensorflow::Status GetVariablesRank( "Variable with name='", variable_names[index], "' has an invalid batch rank of ", batch_rank, "; expected ", *rank); } - return tensorflow::Status(); + return absl::Status(); } REGISTER_OP("Rasterize") @@ -137,7 +137,7 @@ rendered_image: A tensor of shape `[A1, ..., An, width, height, 4]`, with the c->Concatenate(batch_shape, image_shape, &output_shape)); c->set_output(0, output_shape); - return tensorflow::Status(); + return absl::Status(); }); class RasterizeOp : public tensorflow::OpKernel { @@ -176,8 +176,8 @@ class RasterizeOp : public tensorflow::OpKernel { auto rasterizer_creator = [vertex_shader, geometry_shader, fragment_shader, red_clear, green_clear, blue_clear, alpha_clear, depth_clear, enable_cull_face, - this](std::unique_ptr* resource) - -> tensorflow::Status { + this]( + std::unique_ptr* resource) -> absl::Status { return RasterizerWithContext::Create( output_resolution_.dim_size(0), output_resolution_.dim_size(1), vertex_shader, geometry_shader, fragment_shader, resource, red_clear, @@ -219,15 +219,14 @@ class RasterizeOp : public tensorflow::OpKernel { } private: - tensorflow::Status SetVariables( - tensorflow::OpKernelContext* context, - std::unique_ptr& rasterizer, int outer_dim); - tensorflow::Status RenderImage( - tensorflow::OpKernelContext* context, - std::unique_ptr& rasterizer, - tensorflow::int64 image_size, float* image_data); - tensorflow::Status ValidateVariables(tensorflow::OpKernelContext* context, - tensorflow::TensorShape* batch_shape); + absl::Status SetVariables(tensorflow::OpKernelContext* context, + std::unique_ptr& rasterizer, + int outer_dim); + absl::Status RenderImage(tensorflow::OpKernelContext* context, + std::unique_ptr& rasterizer, + tensorflow::int64 image_size, float* image_data); + absl::Status ValidateVariables(tensorflow::OpKernelContext* context, + tensorflow::TensorShape* batch_shape); std::unique_ptr> rasterizer_pool_; @@ -236,7 +235,7 @@ class RasterizeOp : public tensorflow::OpKernel { tensorflow::TensorShape output_resolution_; }; -tensorflow::Status RasterizeOp::RenderImage( +absl::Status RasterizeOp::RenderImage( tensorflow::OpKernelContext* context, std::unique_ptr& rasterizer, const tensorflow::int64 image_size, float* image_data) { @@ -244,10 +243,10 @@ tensorflow::Status RasterizeOp::RenderImage( TF_RETURN_IF_ERROR(rasterizer->Render( num_points, absl::MakeSpan(image_data, image_data + image_size))); - return tensorflow::Status(); + return absl::Status(); } -tensorflow::Status RasterizeOp::SetVariables( +absl::Status RasterizeOp::SetVariables( tensorflow::OpKernelContext* context, std::unique_ptr& rasterizer, int outer_dim) { tensorflow::OpInputList variable_values; @@ -280,10 +279,10 @@ tensorflow::Status RasterizeOp::SetVariables( value_pointer + buffer_length * (outer_dim + 1)))); } } - return tensorflow::Status(); + return absl::Status(); } -tensorflow::Status RasterizeOp::ValidateVariables( +absl::Status RasterizeOp::ValidateVariables( tensorflow::OpKernelContext* context, tensorflow::TensorShape* batch_shape) { tensorflow::OpInputList variable_values; @@ -327,7 +326,7 @@ tensorflow::Status RasterizeOp::ValidateVariables( *batch_shape); } } - return tensorflow::Status(); + return absl::Status(); } // Register kernel with TF diff --git a/tensorflow_graphics/rendering/opengl/rasterizer_with_context.cc b/tensorflow_graphics/rendering/opengl/rasterizer_with_context.cc index b9ceb09a2..eed7367b9 100644 --- a/tensorflow_graphics/rendering/opengl/rasterizer_with_context.cc +++ b/tensorflow_graphics/rendering/opengl/rasterizer_with_context.cc @@ -28,7 +28,7 @@ RasterizerWithContext::RasterizerWithContext( RasterizerWithContext::~RasterizerWithContext() { // Destroy the rasterizer in the correct EGL context. auto status = egl_context_->MakeCurrent(); - if (status != tensorflow::Status()) + if (status != absl::Status()) std::cerr << "~RasterizerWithContext: failure to set the context as current." << std::endl; @@ -39,7 +39,7 @@ RasterizerWithContext::~RasterizerWithContext() { // egl_offscreen_context::Release(). } -tensorflow::Status RasterizerWithContext::Create( +absl::Status RasterizerWithContext::Create( int width, int height, const std::string& vertex_shader_source, const std::string& geometry_shader_source, const std::string& fragment_shader_source, @@ -69,25 +69,25 @@ tensorflow::Status RasterizerWithContext::Create( std::move(offscreen_context), std::move(program), std::move(render_targets), clear_red, clear_green, clear_blue, clear_alpha, clear_depth, enable_cull_face)); - return tensorflow::Status(); + return absl::Status(); } -tensorflow::Status RasterizerWithContext::Render(int num_points, - absl::Span result) { +absl::Status RasterizerWithContext::Render(int num_points, + absl::Span result) { TF_RETURN_IF_ERROR(egl_context_->MakeCurrent()); auto context_cleanup = MakeCleanup([this]() { return this->egl_context_->Release(); }); TF_RETURN_IF_ERROR(Rasterizer::Render(num_points, result)); // context_cleanup calls EGLOffscreenContext::Release here. - return tensorflow::Status(); + return absl::Status(); } -tensorflow::Status RasterizerWithContext::Render( - int num_points, absl::Span result) { +absl::Status RasterizerWithContext::Render(int num_points, + absl::Span result) { TF_RETURN_IF_ERROR(egl_context_->MakeCurrent()); auto context_cleanup = MakeCleanup([this]() { return this->egl_context_->Release(); }); TF_RETURN_IF_ERROR(Rasterizer::Render(num_points, result)); // context_cleanup calls EGLOffscreenContext::Release here. - return tensorflow::Status(); + return absl::Status(); }