|
14 | 14 | #include "tss.h" |
15 | 15 | #include "blenders/blender.h" |
16 | 16 | #include "blenders/blender_recorder.h" |
| 17 | +#include "ShaderResourceTraits.h" |
17 | 18 |
|
18 | 19 | void fix_texture_name(LPSTR fn); |
19 | 20 |
|
@@ -252,98 +253,8 @@ void CResourceManager::_DeleteVS(const SVS* vs) |
252 | 253 | Msg("! ERROR: Failed to find compiled vertex-shader '%s'", *vs->cName); |
253 | 254 | } |
254 | 255 |
|
255 | | -#ifndef _EDITOR |
256 | | -//-------------------------------------------------------------------------------------------------------------- |
257 | | -SPS* CResourceManager::_CreatePS(LPCSTR name) |
258 | | -{ |
259 | | - LPSTR N = LPSTR(name); |
260 | | - map_PS::iterator I = m_ps.find(N); |
261 | | - if (I != m_ps.end()) |
262 | | - return I->second; |
263 | | - else |
264 | | - { |
265 | | - SPS* _ps = new SPS(); |
266 | | - _ps->dwFlags |= xr_resource_flagged::RF_REGISTERED; |
267 | | - m_ps.insert(std::make_pair(_ps->set_name(name), _ps)); |
268 | | - if (0 == xr_stricmp(name, "null")) |
269 | | - { |
270 | | - _ps->sh = nullptr; |
271 | | - return _ps; |
272 | | - } |
273 | | - |
274 | | - // Open file |
275 | | - string_path cname; |
276 | | - LPCSTR shader_path = GEnv.Render->getShaderPath(); |
277 | | - strconcat(sizeof(cname), cname, shader_path, name, ".ps"); |
278 | | - FS.update_path(cname, "$game_shaders$", cname); |
279 | | - |
280 | | - // duplicate and zero-terminate |
281 | | - IReader* file = FS.r_open(cname); |
282 | | - R_ASSERT2(file, cname); |
283 | | - u32 const size = file->length(); |
284 | | - char* const data = (LPSTR)_alloca(size + 1); |
285 | | - CopyMemory(data, file->pointer(), size); |
286 | | - data[size] = 0; |
287 | | - FS.r_close(file); |
288 | | - |
289 | | - // Select target |
290 | | - LPCSTR c_target = "ps_2_0"; |
291 | | - LPCSTR c_entry = "main"; |
292 | | - if (strstr(data, "main_ps_1_1")) |
293 | | - { |
294 | | - c_target = "ps_1_1"; |
295 | | - c_entry = "main_ps_1_1"; |
296 | | - } |
297 | | - if (strstr(data, "main_ps_1_2")) |
298 | | - { |
299 | | - c_target = "ps_1_2"; |
300 | | - c_entry = "main_ps_1_2"; |
301 | | - } |
302 | | - if (strstr(data, "main_ps_1_3")) |
303 | | - { |
304 | | - c_target = "ps_1_3"; |
305 | | - c_entry = "main_ps_1_3"; |
306 | | - } |
307 | | - if (strstr(data, "main_ps_1_4")) |
308 | | - { |
309 | | - c_target = "ps_1_4"; |
310 | | - c_entry = "main_ps_1_4"; |
311 | | - } |
312 | | - if (strstr(data, "main_ps_2_0")) |
313 | | - { |
314 | | - c_target = "ps_2_0"; |
315 | | - c_entry = "main_ps_2_0"; |
316 | | - } |
317 | | - |
318 | | - Msg("compiling shader %s", name); |
319 | | - HRESULT const _hr = GEnv.Render->shader_compile(name, (DWORD const*)data, size, c_entry, c_target, |
320 | | - D3DXSHADER_DEBUG | D3DXSHADER_PACKMATRIX_ROWMAJOR, (void*&)_ps); |
321 | | - |
322 | | - if (FAILED(_hr)) |
323 | | - { |
324 | | - FlushLog(); |
325 | | - } |
326 | | - |
327 | | - CHECK_OR_EXIT(!FAILED(_hr), "Your video card doesn't meet game requirements.\n\nTry to lower game settings."); |
328 | | - |
329 | | - return _ps; |
330 | | - } |
331 | | -} |
332 | | -#endif |
333 | | - |
334 | | -void CResourceManager::_DeletePS(const SPS* ps) |
335 | | -{ |
336 | | - if (0 == (ps->dwFlags & xr_resource_flagged::RF_REGISTERED)) |
337 | | - return; |
338 | | - LPSTR N = LPSTR(*ps->cName); |
339 | | - map_PS::iterator I = m_ps.find(N); |
340 | | - if (I != m_ps.end()) |
341 | | - { |
342 | | - m_ps.erase(I); |
343 | | - return; |
344 | | - } |
345 | | - Msg("! ERROR: Failed to find compiled pixel-shader '%s'", *ps->cName); |
346 | | -} |
| 256 | +SPS* CResourceManager::_CreatePS(LPCSTR name) { return CreateShader<SPS>(name, true); } |
| 257 | +void CResourceManager::_DeletePS(const SPS* ps) { DestroyShader(ps); } |
347 | 258 |
|
348 | 259 | R_constant_table* CResourceManager::_CreateConstantTable(R_constant_table& C) |
349 | 260 | { |
|
0 commit comments