[Bf-blender-cvs] [165f710] master: OpenSubdiv: Make drawing code a bit more flexible for FVar width
Sergey Sharybin
noreply at git.blender.org
Fri Jul 22 15:08:35 CEST 2016
Commit: 165f710519c04192150e685bbb9de3cb52e8bc79
Author: Sergey Sharybin
Date: Fri Jul 22 15:08:18 2016 +0200
Branches: master
https://developer.blender.org/rB165f710519c04192150e685bbb9de3cb52e8bc79
OpenSubdiv: Make drawing code a bit more flexible for FVar width
===================================================================
M intern/opensubdiv/opensubdiv_gpu_capi.cc
===================================================================
diff --git a/intern/opensubdiv/opensubdiv_gpu_capi.cc b/intern/opensubdiv/opensubdiv_gpu_capi.cc
index 16a86f6..452a8ba 100644
--- a/intern/opensubdiv/opensubdiv_gpu_capi.cc
+++ b/intern/opensubdiv/opensubdiv_gpu_capi.cc
@@ -112,6 +112,7 @@ struct OpenSubdiv_GLMeshFVarData
glDeleteTextures(1, &texture_buffer);
}
texture_buffer = 0;
+ fvar_width = 0;
channel_offsets.clear();
}
@@ -122,6 +123,8 @@ struct OpenSubdiv_GLMeshFVarData
{
Release();
+ this->fvar_width = fvar_width;
+
/* Expand fvar data to per-patch array */
const int max_level = refiner->GetMaxLevel();
const int num_channels = patch_table->GetNumFVarChannels();
@@ -166,6 +169,7 @@ struct OpenSubdiv_GLMeshFVarData
}
GLuint texture_buffer;
std::vector<size_t> channel_offsets;
+ int fvar_width;
};
/* TODO(sergey): This is actually duplicated code from BLI. */
@@ -430,22 +434,25 @@ void bindProgram(OpenSubdiv_GLMesh *gl_mesh, int program)
}
/* Face-vertex data */
- if (gl_mesh->fvar_data != NULL && gl_mesh->fvar_data->texture_buffer) {
- glActiveTexture(GL_TEXTURE31);
- glBindTexture(GL_TEXTURE_BUFFER, gl_mesh->fvar_data->texture_buffer);
- glActiveTexture(GL_TEXTURE0);
- }
-
- /* See notes below about why we use such values. */
- /* TOO(sergey): Get proper value for FVar width. */
- glUniform1i(glGetUniformLocation(program, "osd_fvar_count"), 2);
- if (gl_mesh->fvar_data != NULL &&
- gl_mesh->fvar_data->channel_offsets.size() > 0 &&
- g_active_uv_index >= 0)
- {
- glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"),
- gl_mesh->fvar_data->channel_offsets[g_active_uv_index]);
+ if (gl_mesh->fvar_data != NULL) {
+ if (gl_mesh->fvar_data->texture_buffer) {
+ glActiveTexture(GL_TEXTURE31);
+ glBindTexture(GL_TEXTURE_BUFFER, gl_mesh->fvar_data->texture_buffer);
+ glActiveTexture(GL_TEXTURE0);
+ }
+
+ glUniform1i(glGetUniformLocation(program, "osd_fvar_count"),
+ gl_mesh->fvar_data->fvar_width);
+ if (gl_mesh->fvar_data->channel_offsets.size() > 0 &&
+ g_active_uv_index >= 0)
+ {
+ glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"),
+ gl_mesh->fvar_data->channel_offsets[g_active_uv_index]);
+ } else {
+ glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), 0);
+ }
} else {
+ glUniform1i(glGetUniformLocation(program, "osd_fvar_count"), 0);
glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), 0);
}
}
@@ -611,24 +618,22 @@ static GLuint prepare_patchDraw(OpenSubdiv_GLMesh *gl_mesh,
}
/* Face-vertex data */
- if (gl_mesh->fvar_data != NULL &&
- gl_mesh->fvar_data->texture_buffer)
- {
- glActiveTexture(GL_TEXTURE31);
- glBindTexture(GL_TEXTURE_BUFFER,
- gl_mesh->fvar_data->texture_buffer);
- glActiveTexture(GL_TEXTURE0);
+ if (gl_mesh->fvar_data != NULL) {
+ if (gl_mesh->fvar_data->texture_buffer) {
+ glActiveTexture(GL_TEXTURE31);
+ glBindTexture(GL_TEXTURE_BUFFER,
+ gl_mesh->fvar_data->texture_buffer);
+ glActiveTexture(GL_TEXTURE0);
+ }
GLint location = glGetUniformLocation(program, "osd_fvar_count");
if (location != -1) {
- /* TODO(sergey): This is width of FVar data, which happened to be 2. */
- glUniform1i(location, 2);
+ glUniform1i(location, gl_mesh->fvar_data->fvar_width);
}
location = glGetUniformLocation(program, "osd_active_uv_offset");
if (location != -1) {
- if (gl_mesh->fvar_data != NULL &&
- gl_mesh->fvar_data->channel_offsets.size() > 0 &&
+ if (gl_mesh->fvar_data->channel_offsets.size() > 0 &&
g_active_uv_index >= 0)
{
glUniform1i(location,
@@ -637,6 +642,9 @@ static GLuint prepare_patchDraw(OpenSubdiv_GLMesh *gl_mesh,
glUniform1i(location, 0);
}
}
+ } else {
+ glUniform1i(glGetUniformLocation(program, "osd_fvar_count"), 0);
+ glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"), 0);
}
}
return program;
More information about the Bf-blender-cvs
mailing list