Changeset 82693 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Jan 9, 2020 12:58:55 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/shaderlib/shader.c
r81876 r82693 366 366 { 367 367 unsigned int reg_idx = reg->idx; 368 369 if (reg_idx >= MAX_REG_INPUT) 370 { 371 ERR("Invalid input register index %d.\n", reg_idx); 372 return E_INVALIDARG; 373 } 374 368 AssertReturn(reg_idx < MAX_REG_INPUT, E_INVALIDARG); 369 375 370 ((IWineD3DPixelShaderImpl *)shader)->input_reg_used[reg_idx] = TRUE; 376 371 } … … 519 514 /* Mark input registers used. */ 520 515 case WINED3DSPR_INPUT: 521 if (reg_idx >= max(MAX_ATTRIBS, MAX_REG_INPUT)) 522 { 523 ERR("Invalid input register index %d.\n", reg_idx); 524 return E_INVALIDARG; 525 } 516 AssertReturn(reg_idx < max(MAX_ATTRIBS, MAX_REG_INPUT), E_INVALIDARG); 526 517 reg_maps->input_registers |= 1 << reg_idx; 527 518 shader_signature_from_semantic(&input_signature[reg_idx], &semantic); … … 530 521 /* Vertex shader: mark 3.0 output registers used, save token. */ 531 522 case WINED3DSPR_OUTPUT: 532 if (reg_idx >= MAX_REG_OUTPUT) 533 { 534 ERR("Invalid output register index %d.\n", reg_idx); 535 return E_INVALIDARG; 536 } 523 AssertReturn(reg_idx < MAX_REG_OUTPUT, E_INVALIDARG); 537 524 reg_maps->output_registers |= 1 << reg_idx; 538 525 shader_signature_from_semantic(&output_signature[reg_idx], &semantic); … … 542 529 /* Save sampler usage token. */ 543 530 case WINED3DSPR_SAMPLER: 544 if (reg_idx >= RT_ELEMENTS(reg_maps->sampler_type)) 545 { 546 ERR("Invalid sampler index %d.\n", reg_idx); 547 return E_INVALIDARG; 548 } 531 AssertReturn(reg_idx < RT_ELEMENTS(reg_maps->sampler_type), E_INVALIDARG); 549 532 reg_maps->sampler_type[reg_idx] = semantic.sampler_type; 550 533 break; … … 559 542 struct wined3d_shader_src_param rel_addr; 560 543 struct wined3d_shader_dst_param dst; 561 562 local_constant *lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant)); 544 local_constant* lconst; 545 546 fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr); 547 548 AssertReturn(dst.reg.idx < constf_size, E_INVALIDARG); 549 550 lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant)); 563 551 if (!lconst) return E_OUTOFMEMORY; 564 552 565 fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr);566 553 lconst->idx = dst.reg.idx; 567 568 554 memcpy(lconst->value, ptr, 4 * sizeof(DWORD)); 569 555 ptr += 4; … … 589 575 struct wined3d_shader_src_param rel_addr; 590 576 struct wined3d_shader_dst_param dst; 591 592 local_constant *lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant)); 577 local_constant* lconst; 578 579 fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr); 580 581 AssertReturn(dst.reg.idx < MAX_CONST_I, E_INVALIDARG); 582 583 lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant)); 593 584 if (!lconst) return E_OUTOFMEMORY; 594 585 595 fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr);596 586 lconst->idx = dst.reg.idx; 597 598 587 memcpy(lconst->value, ptr, 4 * sizeof(DWORD)); 599 588 ptr += 4; … … 606 595 struct wined3d_shader_src_param rel_addr; 607 596 struct wined3d_shader_dst_param dst; 608 609 local_constant *lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant)); 597 local_constant* lconst; 598 599 fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr); 600 601 AssertReturn(dst.reg.idx < MAX_CONST_B, E_INVALIDARG); 602 603 lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant)); 610 604 if (!lconst) return E_OUTOFMEMORY; 611 605 612 fe->shader_read_dst_param(fe_data, &ptr, &dst, &rel_addr);613 606 lconst->idx = dst.reg.idx; 614 615 607 memcpy(lconst->value, ptr, sizeof(DWORD)); 616 608 ++ptr; … … 729 721 730 722 /* Declare 1.x samplers implicitly, based on the destination reg. number. */ 731 if (shader_version.major == 1 732 && (ins.handler_idx == WINED3DSIH_TEX 733 || ins.handler_idx == WINED3DSIH_TEXBEM 734 || ins.handler_idx == WINED3DSIH_TEXBEML 735 || ins.handler_idx == WINED3DSIH_TEXDP3TEX 736 || ins.handler_idx == WINED3DSIH_TEXM3x2TEX 737 || ins.handler_idx == WINED3DSIH_TEXM3x3SPEC 738 || ins.handler_idx == WINED3DSIH_TEXM3x3TEX 739 || ins.handler_idx == WINED3DSIH_TEXM3x3VSPEC 740 || ins.handler_idx == WINED3DSIH_TEXREG2AR 741 || ins.handler_idx == WINED3DSIH_TEXREG2GB 742 || ins.handler_idx == WINED3DSIH_TEXREG2RGB)) 723 if (ins.handler_idx == WINED3DSIH_TEX 724 || ins.handler_idx == WINED3DSIH_TEXBEM 725 || ins.handler_idx == WINED3DSIH_TEXBEML 726 || ins.handler_idx == WINED3DSIH_TEXDP3TEX 727 || ins.handler_idx == WINED3DSIH_TEXM3x2TEX 728 || ins.handler_idx == WINED3DSIH_TEXM3x3SPEC 729 || ins.handler_idx == WINED3DSIH_TEXM3x3TEX 730 || ins.handler_idx == WINED3DSIH_TEXM3x3VSPEC 731 || ins.handler_idx == WINED3DSIH_TEXREG2AR 732 || ins.handler_idx == WINED3DSIH_TEXREG2GB 733 || ins.handler_idx == WINED3DSIH_TEXREG2RGB) 743 734 { 735 unsigned int sampler_idx; 736 AssertReturn(shader_version.major == 1, E_INVALIDARG); 737 744 738 /* Fake sampler usage, only set reserved bit and type. */ 745 DWORD sampler_code = dst_param.reg.idx; 746 747 if (sampler_code >= RT_ELEMENTS(reg_maps->sampler_type)) 748 { 749 ERR("Invalid sampler index %d.\n", sampler_code); 750 return E_INVALIDARG; 751 } 739 sampler_idx = dst_param.reg.idx; 740 AssertReturn(sampler_idx < RT_ELEMENTS(reg_maps->sampler_type), E_INVALIDARG); 752 741 753 742 TRACE("Setting fake 2D sampler for 1.x pixelshader.\n"); 754 reg_maps->sampler_type[sampler_ code] = WINED3DSTT_2D;743 reg_maps->sampler_type[sampler_idx] = WINED3DSTT_2D; 755 744 756 745 /* texbem is only valid with < 1.4 pixel shaders */ … … 758 747 || ins.handler_idx == WINED3DSIH_TEXBEML) 759 748 { 760 reg_maps->bumpmat |= 1 << dst_param.reg.idx;749 reg_maps->bumpmat |= 1 << sampler_idx; 761 750 if (ins.handler_idx == WINED3DSIH_TEXBEML) 762 751 { 763 reg_maps->luminanceparams |= 1 << dst_param.reg.idx;752 reg_maps->luminanceparams |= 1 << sampler_idx; 764 753 } 765 754 } … … 767 756 else if (ins.handler_idx == WINED3DSIH_BEM) 768 757 { 769 reg_maps->bumpmat |= 1 << dst_param.reg.idx; 758 unsigned int sampler_idx = dst_param.reg.idx; 759 AssertReturn(shader_version.major == 1, E_INVALIDARG); 760 AssertReturn(sampler_idx < RT_ELEMENTS(reg_maps->sampler_type), E_INVALIDARG); 761 762 reg_maps->bumpmat |= 1 << sampler_idx; 770 763 } 771 764 }
Note:
See TracChangeset
for help on using the changeset viewer.