libobs/graphics: Add ability to set shader texture sampler

(Note: This also modifies libobs-d3d11 and libobs-opengl)

Allows overriding the sampler for a specific shader parameter.
This commit is contained in:
jp9000
2016-06-29 04:15:38 -07:00
parent f60952fe09
commit 4dc0024198
10 changed files with 60 additions and 0 deletions

View File

@@ -222,10 +222,18 @@ inline void gs_shader::UpdateParam(vector<uint8_t> &constData,
upload = true;
param.changed = false;
}
} else if (param.curValue.size() == sizeof(gs_texture_t*)) {
gs_texture_t *tex;
memcpy(&tex, param.curValue.data(), sizeof(gs_texture_t*));
device_load_texture(device, tex, param.textureID);
if (param.nextSampler) {
ID3D11SamplerState *state = param.nextSampler->state;
device->context->PSSetSamplers(param.textureID, 1,
&state);
param.nextSampler = nullptr;
}
}
}
@@ -384,3 +392,8 @@ void gs_shader_set_default(gs_sparam_t *param)
shader_setval_inline(param, param->defaultValue.data(),
param->defaultValue.size());
}
void gs_shader_set_next_sampler(gs_sparam_t *param, gs_samplerstate_t *sampler)
{
param->nextSampler = sampler;
}