Skip to content

Commit

Permalink
Automated Code Change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 704099487
  • Loading branch information
tensorflower-gardener authored and copybara-github committed Dec 10, 2024
1 parent 8f60a93 commit 2cca4d0
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 77 deletions.
18 changes: 9 additions & 9 deletions tensorflow_graphics/rendering/opengl/egl_offscreen_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<EGLOffscreenContext>* egl_offscreen_context) {
constexpr std::array<int, 13> kDefaultConfigurationAttributes = {
EGL_SURFACE_TYPE,
Expand All @@ -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,
Expand Down Expand Up @@ -112,10 +112,10 @@ tensorflow::Status EGLOffscreenContext::Create(
surface_cleanup.release();
*egl_offscreen_context = std::unique_ptr<EGLOffscreenContext>(
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.");
Expand All @@ -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();
}
44 changes: 23 additions & 21 deletions tensorflow_graphics/rendering/opengl/gl_program.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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<std::pair<std::string, GLenum>>& shaders,
std::unique_ptr<Program>* program) {
// Create an empty program object.
Expand Down Expand Up @@ -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");

Expand All @@ -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
12 changes: 6 additions & 6 deletions tensorflow_graphics/rendering/opengl/gl_render_targets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<RenderTargets>* render_targets) {
GLuint color_buffer;
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ ShaderStorageBuffer::ShaderStorageBuffer(GLuint buffer) : buffer_(buffer) {}

ShaderStorageBuffer::~ShaderStorageBuffer() { glDeleteBuffers(1, &buffer_); }

tensorflow::Status ShaderStorageBuffer::Create(
absl::Status ShaderStorageBuffer::Create(
std::unique_ptr<ShaderStorageBuffer>* shader_storage_buffer) {
GLuint buffer;

// Generate one buffer object.
TFG_RETURN_IF_EGL_ERROR(glGenBuffers(1, &buffer));
*shader_storage_buffer =
std::unique_ptr<ShaderStorageBuffer>(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
16 changes: 8 additions & 8 deletions tensorflow_graphics/rendering/opengl/rasterizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<float> result) {
absl::Status Rasterizer::Render(int num_points, absl::Span<float> result) {
return RenderImpl(num_points, result);
}

tensorflow::Status Rasterizer::Render(int num_points,
absl::Span<unsigned char> result) {
absl::Status Rasterizer::Render(int num_points,
absl::Span<unsigned char> result) {
return RenderImpl(num_points, result);
}

tensorflow::Status Rasterizer::SetUniformMatrix(
const std::string& name, int num_columns, int num_rows, bool transpose,
absl::Span<const float> matrix) {
absl::Status Rasterizer::SetUniformMatrix(const std::string& name,
int num_columns, int num_rows,
bool transpose,
absl::Span<const float> matrix) {
if (size_t(num_rows * num_columns) != matrix.size())
return TFG_INTERNAL_ERROR("num_rows * num_columns != matrix.size()");

Expand Down Expand Up @@ -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();
}
39 changes: 19 additions & 20 deletions tensorflow_graphics/rendering/opengl/rasterizer_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> variable_names, variable_kinds;
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<RasterizerWithContext>* resource)
-> tensorflow::Status {
this](
std::unique_ptr<RasterizerWithContext>* 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,
Expand Down Expand Up @@ -219,15 +219,14 @@ class RasterizeOp : public tensorflow::OpKernel {
}

private:
tensorflow::Status SetVariables(
tensorflow::OpKernelContext* context,
std::unique_ptr<RasterizerWithContext>& rasterizer, int outer_dim);
tensorflow::Status RenderImage(
tensorflow::OpKernelContext* context,
std::unique_ptr<RasterizerWithContext>& 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<RasterizerWithContext>& rasterizer,
int outer_dim);
absl::Status RenderImage(tensorflow::OpKernelContext* context,
std::unique_ptr<RasterizerWithContext>& rasterizer,
tensorflow::int64 image_size, float* image_data);
absl::Status ValidateVariables(tensorflow::OpKernelContext* context,
tensorflow::TensorShape* batch_shape);

std::unique_ptr<ThreadSafeResourcePool<RasterizerWithContext>>
rasterizer_pool_;
Expand All @@ -236,18 +235,18 @@ class RasterizeOp : public tensorflow::OpKernel {
tensorflow::TensorShape output_resolution_;
};

tensorflow::Status RasterizeOp::RenderImage(
absl::Status RasterizeOp::RenderImage(
tensorflow::OpKernelContext* context,
std::unique_ptr<RasterizerWithContext>& rasterizer,
const tensorflow::int64 image_size, float* image_data) {
int num_points = context->input(0).scalar<int>()();

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<RasterizerWithContext>& rasterizer, int outer_dim) {
tensorflow::OpInputList variable_values;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -327,7 +326,7 @@ tensorflow::Status RasterizeOp::ValidateVariables(
*batch_shape);
}
}
return tensorflow::Status();
return absl::Status();
}

// Register kernel with TF
Expand Down
Loading

0 comments on commit 2cca4d0

Please sign in to comment.